Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the z range in bar3 plot. #1137

Closed
LeeoBianchi opened this issue Mar 11, 2023 · 15 comments
Closed

Setting the z range in bar3 plot. #1137

LeeoBianchi opened this issue Mar 11, 2023 · 15 comments

Comments

@LeeoBianchi
Copy link

LeeoBianchi commented Mar 11, 2023

Hi! Amazing package!

I am trying to plot a 3-d histogram through bar3 with the z-axis starting from 0.0. Is this done through the keyword setting base = 0.0? It seem to get ignored!

G = GMT.mat2grid(randn(5, 6)) cmap = grd2cpt(G); bar3(G, lw=:thinnest, color=cmap, base=0.0, figname="prova.png")

Thank you!

@LeeoBianchi LeeoBianchi changed the title base keyword in bar3 plot gets ignored. Setting the z range in bar3 plot. Mar 11, 2023
@joa-quim
Copy link
Member

Hi! Amazing package!

Thanks, I agree 😃

Humm, it works for me

G = GMT.mat2grid(randn(5, 6));
cmap = grd2cpt(G);
bar3(G, lw=:thinnest, color=cmap, base=0.0, figname="prova.png")

prova

@joa-quim
Copy link
Member

Sorry, I overlooked the base=0.0 part.

@joa-quim
Copy link
Member

@joa-quim
Copy link
Member

Fixed in #1138

@LeeoBianchi
Copy link
Author

LeeoBianchi commented Mar 12, 2023

@joa-quim now the base works! thanks a lot!!

Just a note: in order to adjust the frame accordingly, after having changed base, I had to set both region = [5 65 0.5 5.5 0 300] AND limits = (5, 65, 0.5, 5.5, 0, 300). I don't know it is expected but for me it was not obvious to figure out, maybe something worth mentioning in the docs :)

Cheers,
Leo

@joa-quim
Copy link
Member

No, that is clearly a bug. region and limits are synonyms.

@LeeoBianchi
Copy link
Author

LeeoBianchi commented Mar 12, 2023

No, that is clearly a bug. region and limits are synonyms.

Hmm okay, then definitely a bug!

Moreover, when I am specifying both region and limits, the base keyword becomes unnecessary.
Here is the code to reproduce it:

G = GMT.mat2grid(randn(5, 6).+300, x=[10 20 30 40 50 60], y=[1 2 3 4 5])
cmap = grd2cpt(G);
bar3(G,
     lw=:thinnest,
     color=cmap,
     base=0.0,
     region = [5 65 0.5 5.5 0 600],
     limits = (5, 65, 0.5, 5.5, 0, 600),
     xaxis=(annot=10, ticks=:auto, label="X"),
     yaxis=(annot=1, ticks=:auto, label="Y"),
     zaxis=(annot=:auto, ticks=:auto, label="Z"),
     show = true,
     figsize = (10.5, 9),
     figname="test.png"
     )

@joa-quim
Copy link
Member

Fixed limits/region issue in #1139

Yes, limiting with region to positive only is another way of setting base=0.0

@LeeoBianchi
Copy link
Author

Fixed limits/region issue in #1139

Amazing!

Yes, limiting with region to positive only is another way of setting base=0.0

Yes, that makes sense.

One more thing: what if I wanted to put custom annotations on one of the axis, but leaving the ticks where they are? I haven't found a way to make this work.

In particular in my case I would like a 2 in place of the 0. But if I try to use the xticks keyword I get all the ticks compressed around 0 and the Z axis disappears. Am I doing something wrong?

G = GMT.mat2grid(randn(5, 7).+300, x=[0 10 20 30 40 50 60], y=[1 2 3 4 5])
cmap = grd2cpt(G);
bar3(G,
     lw=:thinnest,
     color=cmap,
     region = [-5 65 0.5 5.5 0 600],
     limits = (-5, 65, 0.5, 5.5, 0, 600),
     xticks=(2, 10, 20, 30, 40, 50, 60),
     show = true,
     figsize = (10.5, 9),
     figname="prova.png"
     )

prova

Cheers,
Leo

@joa-quim
Copy link
Member

You can do this but there must be a better (cleaner to the reader) way

bar3(G, lw=:thinnest, color=cmap, region = [-5 65 0.5 5.5 0 600], xaxis=(custom=(pos=[2, 10, 20, 30, 40, 50, 60], type=["a","a","a","a","a","a","a"]),), yaxis=:a, show=1)

GMTjl_tmp

@joa-quim
Copy link
Member

Simpler this way

bar3(G, lw=:thinnest, color=cmap, region = [-5 65 0.5 5.5 0 600], xticks=([2, 10, 20, 30, 40, 50, 60], ("2","10","20","30","40","50","60")), show=1)

@LeeoBianchi
Copy link
Author

Amazing, it worked! Thank you so much.

Last question, I promise: is there a way to show a grid (or simply thin horizontal lines for each tick) in the background, on the zy plane, for instance?

Leo

@joa-quim
Copy link
Member

No problem with questions, only that I would prefer that they are made in the GMT forum.

The answer is off course yes but needs to dig from the (frame) docs to find the right option.

@joa-quim
Copy link
Member

Can we close this?

@LeeoBianchi
Copy link
Author

Sure, thanks for all the useful tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants