-
Notifications
You must be signed in to change notification settings - Fork 157
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
labels not working #36
Comments
On the latest branch, the following (nearly identical) code works for me:
: 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). |
Hi, I had similar issue with the label, I'm using spyder(anaconda) for mac on python 3.4 |
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. |
matpotlib-1.5 by adding _redraw_labels, i manage to get the labels for the 3 axis. not sure if this is intended
|
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. |
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 |
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? |
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 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? |
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
|
@hareyakana You can manually give the tick labels as an argument to |
@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. |
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. |
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. 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
|
I have tried with the latest master branch and it does not show the axis label without _redraw_labels() |
Ok, thanks. Unfortunately I still cannot reproduce the issue, so for now you'll have to call |
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.
|
I just resize the window after plotting until the spacing looks right; you can also set the image size before calling |
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
|
I don't recall anything like that, but some of the 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. |
Thanks, Marc. Don’t spend too much time on my account. I’ll follow up these hints. j
|
Let us know if you find anything useful. This is something the library could probably handle better. |
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 I assume that when exporting to *.pdf, *.svg and *.eps, there is no 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 |
For now my recommendation is to use _redraw_labels(). Unfortunately we're not also wrapping |
The following code does not produce labels for me. I get the plot, but without any labels.
The text was updated successfully, but these errors were encountered: