SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: wet_colored)arch <wet...@ya...> - 2008年10月30日 22:40:18
I am trying to code an application with two checkboxes, one associated with
each axis on a simple plot. I can then turn on and off lines in the plot
that are scaled either to the left side or right side of the plot.
This is working fine and patterned after some of the examples from
matplotlib.
However, when I use the toolbar feature with the "magnifier" the scaling is
not usually correct. More specifically, if I select an area with the
magnifier, the next drawing of the information is not scaled right. 
(ususally it is a smaller subset of the data selected)
I have confirmed when I run without twinx , the magnifier works fine. 
I also have noticed that when running the example from matplotlib the same
thing happens. I have searched a bit looking for perhaps a bug or comment in
forums on how to workaround this or perhaps I have done something wrong, but
no luck. Perhaps I don't understand how the magnifier is supposed to work
but when I disable the twinx capability of my code, things seem to work
fine. (I'm still mostly a noob but I am persistent.)
I believe I have 0.90 or perhaps one earlier. I wasn't completely sure how
to check but 0.90 is shown in the __init__.py file.
I have attached the matplotlib provided example that I feel doesn't work
right. I also have a snippet of my code below. (which is structured a bit
different than the example but when I run identical to the snippet, using
the structure of my code I get an error due to twinx not being a method of
subplot - as I recall)
from two scales example provided with matplotlib
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
from pylab import *
ax1 = subplot(111)
t = arange(0.01, 10.0, 0.01)
s1 = exp(t)
plot(t, s1, 'b-')
xlabel('time (s)')
ylabel('exp')
# turn off the 2nd axes rectangle with frameon kwarg
ax2 = twinx()
s2 = sin(2*pi*t)
plot(t, s2, 'r.')
ylabel('sin')
ax2.yaxis.tick_right()
show()
snippet from my code >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 self.axL=subplot(132, position=[0.2,0.1,0.6,0.8])
 self.axR=twinx(self.axL)
 self.rax1=subplot(131, position=[0.01, 0.10, 0.14, 0.8])
 self.rax2=subplot(133, position=[0.85, 0.10, 0.14, 0.8])
 
 for key in sorted(dict):
 if dict[key][1]<>'N': #~ providing key to allow for skipping
data set
 visibility=dict[key][2]
 exec("self.l%s, =
self.ax%s.plot(glbl.fusdata%s,visible=visibility,ls=dict[key][4],color=dict[key][3])"%
(key,dict[key][1],key))
 
-- 
View this message in context: http://www.nabble.com/twin---dual---two-axis-seems-to-confuse-or-break-toolbar-magnifier-tp20256700p20256700.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Michael D. <md...@st...> - 2008年11月04日 13:29:50
Can you be more specific about what is going wrong? The zoom magnifier 
seems to work fine for me with or without twinx, but perhaps we just 
have different expectations of how it works. Could you perhaps provide 
screenshots?
I'm checking against SVN trunk. I didn't check against 0.90.1, since it 
would require installing an older version of numpy, and other dependency 
dances etc. But I'm happy to dig further once I have a better idea of 
what is going wrong for you.
This FAQ explains how to get the version number and other useful 
information for a bug report:
http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#report-a-problem
Cheers,
Mike
wet_colored)arch wrote:
> I am trying to code an application with two checkboxes, one associated with
> each axis on a simple plot. I can then turn on and off lines in the plot
> that are scaled either to the left side or right side of the plot.
>
> This is working fine and patterned after some of the examples from
> matplotlib.
>
> However, when I use the toolbar feature with the "magnifier" the scaling is
> not usually correct. More specifically, if I select an area with the
> magnifier, the next drawing of the information is not scaled right. 
> (ususally it is a smaller subset of the data selected)
>
> I have confirmed when I run without twinx , the magnifier works fine. 
>
> I also have noticed that when running the example from matplotlib the same
> thing happens. I have searched a bit looking for perhaps a bug or comment in
> forums on how to workaround this or perhaps I have done something wrong, but
> no luck. Perhaps I don't understand how the magnifier is supposed to work
> but when I disable the twinx capability of my code, things seem to work
> fine. (I'm still mostly a noob but I am persistent.)
>
> I believe I have 0.90 or perhaps one earlier. I wasn't completely sure how
> to check but 0.90 is shown in the __init__.py file.
>
> I have attached the matplotlib provided example that I feel doesn't work
> right. I also have a snippet of my code below. (which is structured a bit
> different than the example but when I run identical to the snippet, using
> the structure of my code I get an error due to twinx not being a method of
> subplot - as I recall)
>
> from two scales example provided with matplotlib
> 
>
> from pylab import *
>
> ax1 = subplot(111)
> t = arange(0.01, 10.0, 0.01)
> s1 = exp(t)
> plot(t, s1, 'b-')
> xlabel('time (s)')
> ylabel('exp')
>
>
> # turn off the 2nd axes rectangle with frameon kwarg
> ax2 = twinx()
> s2 = sin(2*pi*t)
> plot(t, s2, 'r.')
> ylabel('sin')
> ax2.yaxis.tick_right()
> show()
>
>
> snippet from my code >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> self.axL=subplot(132, position=[0.2,0.1,0.6,0.8])
> self.axR=twinx(self.axL)
> self.rax1=subplot(131, position=[0.01, 0.10, 0.14, 0.8])
> self.rax2=subplot(133, position=[0.85, 0.10, 0.14, 0.8])
> 
> for key in sorted(dict):
> if dict[key][1]<>'N': #~ providing key to allow for skipping
> data set
> visibility=dict[key][2]
> exec("self.l%s, =
> self.ax%s.plot(glbl.fusdata%s,visible=visibility,ls=dict[key][4],color=dict[key][3])"%
> (key,dict[key][1],key))
> 
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
On Tue, Nov 4, 2008 at 7:29 AM, Michael Droettboom <md...@st...> wrote:
> Can you be more specific about what is going wrong? The zoom magnifier
> seems to work fine for me with or without twinx, but perhaps we just
> have different expectations of how it works. Could you perhaps provide
> screenshots?
Note that only one of the two axes can get the events, and that is
determined by the axes zorder. So if you want ax1 to get the events
 ax1 = fig.add_subplot(111)
 ax1t = ax1.twinx()
 ax1.set_zorder(10)
 ax1t.set_zorder(1)
JDH
From: wet_colored)arch <wet...@ya...> - 2008年11月05日 00:52:28
Can you be more specific about what is going wrong? The zoom magnifier 
seems to work fine for me with or without twinx, but perhaps we just 
have different expectations of how it works. Could you perhaps provide 
screenshots?
Response>>
I confirmed it is 0.90.0 (I am running on Windows)
attached is code (which is simply example packaged with matplot lib)
ALSO: 
the default figure: of which I selected the region from 2-4 on the x-axis
for magnifying
the resulting figure from magnifying: you can see much of the content from
2-4 is missing (I selected the entire y axis with the magnifier) -- the
xaxis is only selecting a subset of the range I chose
the expected figure: I used the crossed arrows instead of the magnifier to
create a plot figure that roughly mimics what I expected... I expected to
see all data in y from x = 2 to 4
Is my expectation wrong? I expect the x and y axis range selected by the
magnifier tool to be fully represented in the subsequent representation of
the data - it always seems to be subset of the data range chosen.
http://www.nabble.com/file/p20334562/two_scales.py two_scales.py 
http://www.nabble.com/file/p20334562/two_scales_baseline.png
two_scales_baseline.png 
http://www.nabble.com/file/p20334562/two_scales_2to4_concern.png
two_scales_2to4_concern.png 
http://www.nabble.com/file/p20334562/two_scales_2to4_expectation.png
two_scales_2to4_expectation.png 
-- 
View this message in context: http://www.nabble.com/twin---dual---two-axis-seems-to-confuse-or-break-toolbar-magnifier-tp20256700p20334562.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Michael D. <md...@st...> - 2008年11月05日 14:14:19
Thanks for the re-explanation. I can confirm that this is broken as 
recently as 0.91.2. However, it works as expected with a recent SVN 
trunk, and matplotlib 0.98.3.
It seems what this is doing is adjusting the limits twice (for each of 
the twin axes), the first correctly, and then again by applying the same 
rectangle to the adjusted limits.
I will go ahead and fix this on the 0.91.x maintenance branch. (It 
seems Sourceforge's SVN is down at the moment, so I can't right now). 
I've also attached a patch that *may* apply to 0.90.0. It's a lot of 
work for me to move back to that version to test given the change in 
Numpy dependencies etc. If the patch doesn't work for you, you may just 
want to consider upgrading to the most recent 0.98.x.
Cheers,
Mike
wet_colored)arch wrote:
> Can you be more specific about what is going wrong? The zoom magnifier 
> seems to work fine for me with or without twinx, but perhaps we just 
> have different expectations of how it works. Could you perhaps provide 
> screenshots?
>
> Response>>
> I confirmed it is 0.90.0 (I am running on Windows)
> attached is code (which is simply example packaged with matplot lib)
>
> ALSO: 
>
> the default figure: of which I selected the region from 2-4 on the x-axis
> for magnifying
> the resulting figure from magnifying: you can see much of the content from
> 2-4 is missing (I selected the entire y axis with the magnifier) -- the
> xaxis is only selecting a subset of the range I chose
> the expected figure: I used the crossed arrows instead of the magnifier to
> create a plot figure that roughly mimics what I expected... I expected to
> see all data in y from x = 2 to 4
>
> Is my expectation wrong? I expect the x and y axis range selected by the
> magnifier tool to be fully represented in the subsequent representation of
> the data - it always seems to be subset of the data range chosen.
>
> http://www.nabble.com/file/p20334562/two_scales.py two_scales.py 
> http://www.nabble.com/file/p20334562/two_scales_baseline.png
> two_scales_baseline.png 
> http://www.nabble.com/file/p20334562/two_scales_2to4_concern.png
> two_scales_2to4_concern.png 
> http://www.nabble.com/file/p20334562/two_scales_2to4_expectation.png
> two_scales_2to4_expectation.png 
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /