Comments (24)
matpotlib-1.5
ipython-4.0.1
spyder-2.3.7
by adding _redraw_labels, i manage to get the labels for the 3 axis. not sure if this is intended
d.set_title(r"source flavour composition $\nu_e,\nu_\mu,\nu_\tau$",fontsize=20)
d.left_axis_label(r"$|\nu_e|$",fontsize=15)
d.right_axis_label(r"$|\nu_\mu|$",fontsize=15)
d.bottom_axis_label(r"$|\nu_\tau|$",fontsize=15)
d._redraw_labels()
from python-ternary.
On the latest branch, the following (nearly identical) code works for me:
import ternary
import matplotlib.pyplot as pyplot
scale, fontsize = 1, 12
figure, ax = pyplot.subplots()
tax = ternary.TernaryAxesSubplot(ax=ax)
tax.set_title("Evolution of 6-6-3 signaler games under ambiguity", fontsize=fontsize)
tax.left_axis_label("Left label $\\alpha^2$", fontsize=fontsize)
tax.right_axis_label("Right label $\\beta^2$", fontsize=fontsize)
tax.bottom_axis_label("Bottom label $\\Gamma - \\Omega$", fontsize=fontsize)
tax.boundary(linewidth=2.0)
tax.gridlines(multiple=0.1, color="blue")
tax.plot( ((0.1,0.8,0.1),(0.8,0.1,0.1)) )
#tax.scatter( x, marker='s')
tax.legend()
tax.ticks(axis='lbr', linewidth=1, multiple=0.1)
tax.show()
: http://postimg.org/image/qmh1f7mpl/full/
Are you using an older version of matplotlib? Someone else reported something similar a while ago. I just used mpl 1.4.2 on python 2.7 and python 3.4.3 (the Ubuntu packaged versions).
from python-ternary.
Hi, I had similar issue with the label, I'm using spyder(anaconda) for mac on python 3.4
from python-ternary.
I appreciate the reports but I really need more information. The matplotlib version seems to be important -- this may be an upstream issue, or something that can be worked around.
I don't have a Mac to test with.
from python-ternary.
That is helpful -- the labels have to be redrawn on resizing and other operations so that the angles are right. I can add more rendering hooks.
If you show the image and resize the window do the labels appear? Perhaps there is a difference in rendering or event handling based on the backend or mpl version.
from python-ternary.
figure, d=t.figure(scale=1)
d.boundary(linewidth=2.0)
d.gridlines(multiple=0.1,color="blue",linewidth=0.8)
d.gridlines(multiple=0.02,color="green",linewidth=0.4)
d.set_title(r"source flavour composition $\nu_e,\nu_\mu,\nu_\tau$",fontsize=20)
d.left_axis_label(r"$|\nu_e|$",fontsize=15)
d.right_axis_label(r"$|\nu_\mu|$",fontsize=15)
d.bottom_axis_label(r"$|\nu_\tau|$",fontsize=15)
#d._redraw_labels()
d.ticks(axis='rlb',multiple=0.1,axes_colors={'l': 'g', 'r':'b', 'b': 'r'},clockwise=False,label=ticks)
p.axis('off')
point=[(1/3,1/3,1/3)]
d.scatter(point, marker='D', color='green', label="Green Diamonds",)
d.resize_drawing_canvas(scale=1.05)
d.legend
d.show()
after i uncomment _redraw_labels() line, I was able to get the label shown
from python-ternary.
my ipython console renders the image in a separate interactive window, I could do it inline but would prefer a separate window to check on the plots. I have try tinker with the offset with various value but it just does not show the label without the _redraw_labels line.
while my code i pasted here, is there any way I could change the orientation of the ticks? with the clockwise=True
but maintaining the same orientation as clockwise=False
. I have check some of the past closed issues but can't get my head around it.
from python-ternary.
I added the label draw callback to the "draw_event" of mpl -- hopefully that causes the labels to be drawn initially as expected. The label positioning does not take much into account: there's no easy way to predict what the latex will render to as far as I know, what all the font-sizes are, etc., so you'll have to adjust the offsets as needed.
I'm not sure what you are asking regarding the tick orientation -- the library implements the two standard choices. Can you be more specific?
from python-ternary.
something similar to issue#31
I am trying to produce something similar to this https://inspirehep.net/record/1343979/files/flav_scan-eps-converted-to.png
but I can't seem to get for example the bottom axis to go 0 to 1 instead of 1 to 0. When I try to add clockwise=True
to ticks
. It does go 0 to 1 but the orientation changes.
from issue #31,`I can't seem to understand the phrase u mentioned "You can pass clockwise=True to ticks to reverse the orientation (which changes the tick angles)." right after the second plot image. would you elaborate on that?
from python-ternary.
Resizing didn’t help, but…adding _redraw_labels() DID!
I haven’t pulled the latest github version, so this is using the version I had with my original comment.
j
On Nov 29, 2015, at 2:16 PM, Marc Harper, PhD [email protected] wrote:
I added the label draw callback to the "draw_event" of mpl -- hopefully that causes the labels to be drawn initially as expected. The label positioning does not take much into account: there's no easy way to predict what the latex will render to as far as I know, what all the font-sizes are, etc., so you'll have to adjust the offsets as needed.
I'm not sure what you are asking regarding the tick orientation -- the library implements the two standard choices. Can you be more specific?
—
Reply to this email directly or view it on GitHub #36 (comment).
from python-ternary.
@hareyakana You can manually give the tick labels as an argument to tax.ticks(ticks=[])
to change the default labeling order. If you need something other than the two orientations for some reason them you'll have to transform the data before plotting.
from python-ternary.
@jamesafoster that's bizarre. I'm glad there is a workaround for now. My guess is that various combinations of mpl backend and version trigger events differently, and so sometimes label drawing doesn't occur.
from python-ternary.
If either of you can check the github master branch that would be most appreciated. If it's fixed I'll push a new pypi version.
from python-ternary.
I still don’t get labels unless I re-size (yes, that works now…I think I may not have tested it correctly before), or redraw the axes.
I get the following message: /Users/jamesafoster/anaconda/lib/python3.4/site-packages/matplotlib/axes/_axes.py:475: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labelled objects found. "
To be honest, I’m not sure I downloaded the correct build. On gitgub, I think I’m looking at teh master branch, and I downloaded and installed that.
Thanks for looking into this!
j
James A. Foster
Professor, University of Idaho
Institute for Bioinformatics & Evolutionary STudies (IBEST)
> On Nov 30, 2015, at 12:19 PM, Marc Harper, PhD <[email protected]> wrote:
>
> If either of you can check the github master branch that would be most appreciated. If it's fixed I'll push a new pypi version.
>
> —
> Reply to this email directly or view it on GitHub <https://github.com/marcharper/python-ternary/issues/36#issuecomment-160749250>.
>
from python-ternary.
I have tried with the latest master branch and it does not show the axis label without _redraw_labels()
from python-ternary.
Ok, thanks. Unfortunately I still cannot reproduce the issue, so for now you'll have to call _redraw_labels()
manually.
from python-ternary.
In our earlier exchange, you had one example of code that moved labels out from the ternary plot tick marks. But I lost it! How did you do that??
This is what I have, and I’m trying to make it look better.
Thanks for any pointers.
James A. Foster
Professor, University of Idaho
Institute for Bioinformatics & Evolutionary STudies (IBEST)
> On Nov 29, 2015, at 9:39 AM, hareyakana <[email protected]> wrote:
>
> matpotlib-1.5
> ipython-4.0.1
> spyder-2.3.7
>
> by adding _redraw_labels, i manage to get the labels for the 3 axis. not sure if this is intended
>
> d.set_title(r"source flavour composition $\nu_e,\nu_\mu,\nu_\tau$",fontsize=20)
> d.left_axis_label(r"$|\nu_e|$",fontsize=15)
> d.right_axis_label(r"$|\nu_\mu|$",fontsize=15)
> d.bottom_axis_label(r"$|\nu_\tau|$",fontsize=15)
> d._redraw_labels()
> —
> Reply to this email directly or view it on GitHub <https://github.com/marcharper/python-ternary/issues/36#issuecomment-160435267>.
>
from python-ternary.
I just resize the window after plotting until the spacing looks right; you can also set the image size before calling pyplot.savefig()
. Unfortunately this isn't something that is easy to do automatically because of differences in font size and screen size. If anyone has ideas, please share.
from python-ternary.
Thanks for that!
You also had a call that moved the tick labels and the labels on the edges OUT further. I think it was a call to an underlying matplotlib method, but I can’t find or remember what it was. Do you? (I’m new with matplotlib, so I suspect the answer is not specific to ternary and is probably known to most people who use matplotlib).
j
On Dec 19, 2015, at 10:32 AM, Marc Harper [email protected] wrote:
I just resize the window after plotting until the spacing looks right; you can also set the image size before calling pyplot.savefig(). Unfortunately this isn't something that is easy to do automatically because of differences in font size and screen size. If anyone has ideas, please share.
—
Reply to this email directly or view it on GitHub #36 (comment).
from python-ternary.
I don't recall anything like that, but some of the ternary
methods do take an offset parameter that should move the labels outward a bit. Resizing the image window after pyplot.show()
does have a similar effect in many cases. You can also reduce the font size.
I would prefer the library to do this automatically, but AFAIK there is not a good way to determine the rendering size of a label beforehand. I'll look into again.
from python-ternary.
Thanks, Marc. Don’t spend too much time on my account. I’ll follow up these hints.
j
On Dec 19, 2015, at 10:57 AM, Marc Harper [email protected] wrote:
I don't recall anything like that, but some of the ternary methods do take an offset parameter that should move the labels outward a bit. Resizing the image window after pyplot.show does have a similar effect in many cases. You can also reduce the font size.
I would prefer the library to do this automatically, but AFAIK there is not a good way to determine the rendering size of a label beforehand. I'll look into again.
—
Reply to this email directly or view it on GitHub #36 (comment).
from python-ternary.
Let us know if you find anything useful. This is something the library could probably handle better.
from python-ternary.
I ran into a similar issue that labels are not drawn under certain circumstances. It seems to be related to the fact that rasterized outputs are treated differently by matplotlib than vector images.
The following code produces the expected output if rendered to .png, but the labels are missing from the diagrams if it's exported to .pdf, unless _redraw_labels()
is called manually before saving.
I assume that when exporting to *.pdf, *.svg and *.eps, there is no draw_event
emitted by matplotlib. Is there a better way to do this?
fig, axes = plt.subplots(1,2,figsize=(5, 2))
fig, tax1 = ternary.figure(scale=4, ax=axes[0])
fig, tax2 = ternary.figure(scale=4, ax=axes[1])
for tax in [tax1, tax2]:
tax.boundary()
tax.bottom_axis_label("a")
tax.right_axis_label("b")
tax.left_axis_label("c")
for ax in axes:
ax.axis("off")
tax2._redraw_labels()
fig.savefig("./testtriangles.pdf", bbox_inches='tight') # Only labels of tax2 are drawn
fig.savefig("./testtriangles.png", bbox_inches='tight') # All labels are drawn
from python-ternary.
For now my recommendation is to use _redraw_labels(). Unfortunately we're not also wrapping fig
because the solution in that case would be to override savefig
to always redraw first. And that won't work for tax
because it could be part of a larger plot or there could be multiple figures.
from python-ternary.
Related Issues (20)
- Scatter creates equilateral plot HOT 1
- Question on ternary heatmap plot HOT 1
- Can not set the limits of each axis? HOT 1
- Heatmap scale greater than 1 vs less than equal to 1 HOT 4
- Cut off top of triangle? HOT 5
- Problem in making the ternary heatmap if the key interval is not 1. HOT 1
- TernaryAxesSubplot.scatter() skips first default color in version 1.0.8 HOT 1
- How to plot the Ternary Choropleth Map? HOT 3
- Heatmap polygon triangles and gridlines don't meet exactly HOT 4
- Blank Heatmap HOT 6
- Plot Blocking Option
- Custom Axis Directions HOT 2
- Cannot set transparent background HOT 1
- Issues with corner label positions under panning/zooming HOT 4
- change font, and output an equilateral triangle HOT 2
- Can't find a way that works to reduce label overlap. HOT 2
- Update installation metadata
- Remove number
- Text annotations HOT 1
- Add pyproject.toml file for python 3.12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-ternary.