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

incompatible bar label #74

Closed
halilSozen opened this issue Nov 10, 2017 · 10 comments
Closed

incompatible bar label #74

halilSozen opened this issue Nov 10, 2017 · 10 comments
Assignees
Labels

Comments

@halilSozen
Copy link

Dear Marc,

I am trying your example code colorbar_kwargs.py for my system. I am willing to plot my ternary phase diagram with calculated free energies. I have tried for some test case and realized that the free energy (i.e scatter points c values) are not really compatible with bar label. For instance, I have selected 3 points with 0, -5 and -9.5 values (in vmin=-10, vmax=0 range ).
`# Scatter some points
points = [(2,3,5),(2,1,7),(2,5,2)]
c = [0, -5, -9.5]

cb_kwargs = {"shrink" : 0.6,
"orientation" : "horizontal",
"fraction" : 0.1,
"pad" : 0.05,
"aspect" : 30}

tax.scatter(points,marker='s',c=c,edgecolor='k',s=80,linewidths=0.5,
vmin=-10, vmax=0, colorbar=True,colormap='jet',cbarlabel='Free Energy (eV)',
cb_kwargs=cb_kwargs,zorder=3)`

Under that circumstances I suppose to have blue, green and red circles in the phase diagram, but this is not the case as seen in the image attached.

If you can give me a feedback, I will be appreciated.
Thanks,
Halil

test

@marcharper
Copy link
Owner

I think the example you want to follow is the colored scatter plot. It looks to me like the scatter plot colors are being set by the cmap parameter (which is the viridis color map by default). To make the points circles the marker parameter should be marker='o'.

So it's possible that there is a bug with the colormap parameters / precedence. If that is the case, let me know and I'll fix it.

@halilSozen
Copy link
Author

Dear Marc,

Thanks a lot for quick response. I believe colorbar_kwargs.py is best for me. Because it has labels in 3 edges of the triangle (namely element x,y anz z compositions). So my compound can be understood easily. Also in later I may try to write the label next to my circles (such as X_(2)Y_(5)Z_(2)), so the reader can understand better.

I have only the problem that c values that I entered are not plotted correctly according to the color bar scale. Do you think it is because viridis ?

Making markers circles are completely fine :)

@marcharper
Copy link
Owner

Try using the cmap argument instead.

@halilSozen
Copy link
Author

Great ! That works, thanks a lot 👍

@marcharper marcharper self-assigned this Nov 14, 2017
@marcharper marcharper added the bug label Nov 14, 2017
@marcharper
Copy link
Owner

Great, thanks for the report. I'll update the functions to remove the duplicate colormap parameter.

@halilSozen
Copy link
Author

btw, short question: how can I change the fontsize and ticks in colorbar in colorbar_kwargs.py ?

@marcharper
Copy link
Owner

The kwargs simply get passed through to matplotlib so you have to use the parameters as expected by those functions. If you need examples, search for e.g. "changing matplotlib colorbar ticks" and you should get several examples from stack overflow and other sites.

@halilSozen
Copy link
Author

Dear Marc,

I was trying hard but could not really figure out. I did the corresponding changes in the colorbar_kwargs.py code:

cb=tax.scatter(points,marker='o',c=c,cmap=plt.cm.jet,edgecolor='k',s=80,linewidths=0.5,
vmax=0.04,vmin=-1.95,colorbar=True,colormap=plt.cm.jet, cbarlabel=' Free Energy per atom (eV)',
cb_kwargs=cb_kwargs, zorder=3)

ticklabels=cb.get_yticklabels()
cb.set_yticklabels(ticklabels, fontsize=100)
cb.tick_params(labelsize=100)

but still it is not working. Could you please give me further advices ?

@marcharper
Copy link
Owner

The colorbar arguments need to go in the cb_kwargs dictionary, e.g. take the existing cb_kwargs and add fontsize:

cb_kwargs["fontsize"] = 100

Then pass cb_kwargs to tax.scatter as above. Note that 100 is a very large fontsize...

@marcharper
Copy link
Owner

Colorbar arguments clarified in the master branch, closing as fixed.

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

No branches or pull requests

2 participants