marcharper / python-ternary

:small_red_triangle: Ternary plotting library for python with matplotlib
MIT License
730 stars 157 forks source link

Ask: Sharing the same color-bar between several ternary graphs #72

Closed akinori8888 closed 7 years ago

akinori8888 commented 7 years ago

I want to share color-bar between several ternary graphs which have individual value-range. For example, value-range of graph A is (0, 67), value-range of graph B is (65, 202) I want the color-bar which fits both of graph A and graph B.

Now, I have two color-bars and set of (color and number) does not match between A and B

marcharper commented 7 years ago

You can pass in parameters for the color bar limits (vmax and vmin), see here.

If you want one colorbar for all your plots, that's controllable by matplotlib, try this link or search for similar.

akinori8888 commented 7 years ago

I really appreciate your answer, I'll try that.

akinori8888 commented 7 years ago

Additional question, sorry. Is there any function to describe the number in each cell of heatmap like the picture below in python-ternary? default

akinori8888 commented 7 years ago

Sorry for successive questions. I tried following to your answer, but there are three questions. I could set vmin and vmax

  1. How to delete ticks outside the figure, vertical and horizontal ticks of (0,2,4,6,8,10)?

  2. How can I set ticks numbers from (1,2,3,4,5,6,7,8,9,10) to (0.1,0.2,0.3,0.4 ....) ?

  3. How to create subplots and put ternary graph inside the subplots? this is related to the previous question.

image

marcharper commented 7 years ago

Is there any function to describe the number in each cell of heatmap like the picture below in python-ternary?

There's not a built in function but you could supply the coordinates and use tax.annotate(...) to directly add the text.

  1. How to delete ticks outside the figure, vertical and horizontal ticks of (0,2,4,6,8,10)?

You can turn off matplotlib's axis ticks with

tax.clear_matplotlib_ticks()
  1. How can I set ticks numbers from (1,2,3,4,5,6,7,8,9,10) to (0.1,0.2,0.3,0.4 ....) ?

You can change the scaling or overwrite the tick values directly. See this example.

How to create subplots and put ternary graph inside the subplots? this is related to the previous question.

You can wrap the matplotlib axis for the subplot like so:

 figure, ax = pyplot.subplots()
    tax = ternary.TernaryAxesSubplot(ax=ax)

Or using gridspec:

   from matplotlib import pyplot, gridspec

    pyplot.figure()
    gs = gridspec.GridSpec(2,2)
    ax = pyplot.subplot(gs[0,0])
    figure, tax = ternary.figure(ax=ax)
akinori8888 commented 7 years ago

Thanks for your kind answer, I made it!

marcharper commented 7 years ago

If you'd like to contribute a plot to the examples please let me know!