annotate

Hi,

The following code displays a figure with both a red and a blue arrow (generated by annotate). But the pdf that is saved only shows the red one. It seems that the line ax1.set_xscale('log') is causing the trouble, because if it is commented out, the blue arrow reappears in the pdf. Any hints?

import numpy as np
from matplotlib import pyplot as pp

fig = pp.figure()
ax2 = fig.add_subplot(111)
ax1 = ax2.twinx()
ax1.set_xlim(xmin=100,xmax=10000)
ax1.set_ylim(ymin=-60, ymax=5)
ax1.set_xscale('log')
ax2.set_xlim(xmin=100,xmax=10000)
ax2.set_ylim(ymin=-5,ymax=35)
ax2.set_xscale('log')

ax1.annotate("", (10000,-30), (2000,-30),
              arrowprops=dict(arrowstyle="-|>",fc="b", ec="b"))
ax2.annotate("", (100, 5), (2000, 5),
              arrowprops=dict(arrowstyle="-|>",fc="r", ec="r"))
pp.savefig('test_arrow.pdf')
pp.show()

···

--
Christopher Brown, Ph.D.
Associate Research Professor
Department of Speech and Hearing Science
Arizona State University
http://pal.asu.edu

Thanks for the report. I have created a pull request with a solution for this bug here:

https://github.com/matplotlib/matplotlib/pull/403

If you are able to build from git, test these changes and give me feedback in your specific environment, that would be great.

Cheers,
Mike

···

On 07/14/2011 04:59 PM, Christopher Brown wrote:

Hi,

The following code displays a figure with both a red and a blue arrow
(generated by annotate). But the pdf that is saved only shows the red
one. It seems that the line ax1.set_xscale('log') is causing the
trouble, because if it is commented out, the blue arrow reappears in the
pdf. Any hints?

import numpy as np
from matplotlib import pyplot as pp

fig = pp.figure()
ax2 = fig.add_subplot(111)
ax1 = ax2.twinx()
ax1.set_xlim(xmin=100,xmax=10000)
ax1.set_ylim(ymin=-60, ymax=5)
ax1.set_xscale('log')
ax2.set_xlim(xmin=100,xmax=10000)
ax2.set_ylim(ymin=-5,ymax=35)
ax2.set_xscale('log')

ax1.annotate("", (10000,-30), (2000,-30),
               arrowprops=dict(arrowstyle="-|>",fc="b", ec="b"))
ax2.annotate("", (100, 5), (2000, 5),
               arrowprops=dict(arrowstyle="-|>",fc="r", ec="r"))
pp.savefig('test_arrow.pdf')
pp.show()

--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA