<div dir="ltr">Sorry this caused grief for you.  There is definitely a tension when working on a library as big, old, and widely used as mpl, we want to make things better, but we are almost always going to break something for someone (even bug fixes break people who have work-arounds to the bug-fixes!).<div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 4, 2016 at 8:39 AM Oliver Willekens <<a href="mailto:oliver.willekens@gmail.com">oliver.willekens@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>>[...] in general [DPI/figure issues] will come up because the Transforms close over many 
values that can (and do!) change from user input or as part of the draw 
process.<br><br>Thought I had the transformations all figured out, but it looks like I should definitely play some more with it.<br><br>Thank you, Tom, for referring me to the git pull request and explaining the cause of this.<br><br></div></div></div><div dir="ltr"><div><div>Oliver<br></div><div><br></div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-03 14:54 GMT+01:00 Thomas Caswell <span dir="ltr"><<a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If you want to _really_ force a redraw, you will need to to `fig.canvas.draw()`.  <div><br></div><div>In <a href="https://github.com/matplotlib/matplotlib/pull/5150" target="_blank">https://github.com/matplotlib/matplotlib/pull/5150</a> we change `plt.draw()` to use the `canvas.draw_idle` method.  The draw_idle effectively asks the GUI framework to please re-draw the next time it is convenient.  The main benefit of this is if you request multiple draw_idle before giving the GUI a chance to re-paint there will only be one actual call to `canvas.draw`.</div><div><br></div><div>Using `ax.text` is much simpler you should just use that ;)</div><div><br></div><div>In general going through screen coordinates in user code is not advised.  In this particular case you are going right back to 'normalized' unit so you will not have DPI / figure size issues, but in general those will come up because the Transforms close over many values that can (and do!) change from user input or as part of the draw process.  In almost all cases, it is better to pass a transfrom into the artists and let mpl internals sort of exactly when to evaluate them.</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div><div><div dir="ltr">On Thu, Mar 3, 2016 at 6:31 AM Oliver Willekens <<a href="mailto:oliver.willekens@gmail.com" target="_blank">oliver.willekens@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><p style="margin:1.2em 0px!important">Dear matplotlib users and developers,</p>
<p style="margin:1.2em 0px!important">I’m  using <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">plt.draw()</code> to force the rendering of all artists and then,  based on their newly calculated positions, place a text label on the  figure window in figure coordinates. </p>
<p style="margin:1.2em 0px!important">The goal is to add a text  label near the conventional y-axis, at the top, right-aligned. Example  code that demonstrates the problem:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,255) none repeat scroll 0% 0%">#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
print(mpl.__version__)

x = np.linspace(0, 50)
y = 4*np.sin(x) + 5

fig = plt.figure(figsize=(18,9.8))
ax = fig.add_axes((0.1, 0.1, 0.8, 0.8),
    frameon=True,
    aspect='equal',
    adjustable='box',
    xlim=(x.min(), x.max()),
    ylim=(0, 10),
    xticks=[x.min(), x.max()],
    yticks=[0, 10],
    xlabel='dimension (unit)')
ax.plot(x, y)
plt.draw()  # force redraw

ylabel_pos = fig.transFigure.inverted().transform_point(ax.transAxes.transform_point((0,1)))
label1 = fig.text(ylabel_pos[0], ylabel_pos[1], "label1", ha="right", va="bottom")
plt.savefig('/tmp/test_pre_mpl_v_{}.png'.format(mpl.__version__))
ylabel_pos = fig.transFigure.inverted().transform_point(ax.transAxes.transform_point((0,1)))
label2 = fig.text(ylabel_pos[0], ylabel_pos[1], "label2", ha="right", va="bottom")
plt.savefig('/tmp/test_post_mpl_v_{}.png'.format(mpl.__version__))
</code></pre><p style="margin:1.2em 0px!important">The  code shows that in mpl 1.4.3 both label1 and label2 end up at the same  (desired) position. However, mpl 1.5.0 and 1.5.1 (just installed to  check) show that label1 is at a height of 0.9 in the figure coordinates.  After the first call to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">savefig</code>, the figure is rendered with the axes  getting a new height and width (due to the call to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">aspect='equal',  adjustable='box'</code>) and so the subsequent call to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">savefig</code> renders  label2 in the correct position.</p>
<p style="margin:1.2em 0px!important">Using <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">ax.text(x=0, y=1,  s='label', transform=ax.transAxes, ha="right", va="bottom")</code> gets the  job done alright (both in 1.4.3, as well as 1.5.0), but the call to  <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">fig.text</code> using the subsequent transforms should have worked, I  believe, and so this seems to indicate something has changed in the rendering of a rescaled axes using <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">plt.draw</code>.</p>
<p style="margin:1.2em 0px!important">Kind regards,<br>Oliver</p>
<p style="margin:1.2em 0px!important">P.S. I posted this to the older sourceforge mailing list as well, by accident. Hadn’t changed the send-to address yet, even though Thomas Caswell had pointed it out to me already in August 2015. My apologies.</p>
<div title="MDH:PGRpdiBpZD0iOjk5MSIgY2xhc3M9IiI+PGRpdiBpZD0iOjk5MiIgY2xhc3M9IiIgc3R5bGU9Im92
ZXJmbG93OiBoaWRkZW47Ij48ZGl2IGRpcj0ibHRyIj48ZGl2PjxkaXY+PGRpdj48ZGl2PkRlYXIg
PHNwYW4gY2xhc3M9IiI+bWF0cGxvdGxpYjwvc3Bhbj4gdXNlcnMgYW5kIGRldmVsb3BlcnMsPGJy
Pjxicj5JJ20KIHVzaW5nIGBwbHQuZHJhdygpYCB0byBmb3JjZSB0aGUgcmVuZGVyaW5nIG9mIGFs
bCBhcnRpc3RzIGFuZCB0aGVuLCAKYmFzZWQgb24gdGhlaXIgbmV3bHkgY2FsY3VsYXRlZCBwb3Np
dGlvbnMsIHBsYWNlIGEgdGV4dCBsYWJlbCBvbiB0aGUgCmZpZ3VyZSB3aW5kb3cgaW4gZmlndXJl
IGNvb3JkaW5hdGVzLiA8YnI+PGJyPlRoZSBnb2FsIGlzIHRvIGFkZCBhIHRleHQgCmxhYmVsIG5l
YXIgdGhlIGNvbnZlbnRpb25hbCB5LWF4aXMsIGF0IHRoZSB0b3AsIHJpZ2h0LWFsaWduZWQu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3QgY2hhbmdl
ZCB0aGUgc2VuZC10byBhZGRyZXNzIHlldCwgZXZlbiB0aG91Z2ggVGhvbWFzIENhc3dlbGwgaGFk
IHBvaW50ZWQgaXQgb3V0IHRvIG1lIGFscmVhZHkgaW4gQXVndXN0IDIwMTUuIE15IGFwb2xvZ2ll
cy48YnI+PC9kaXY+PC9kaXY+PC9kaXY+" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div></div></div>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div>
</blockquote></div><br></div>
</blockquote></div>