SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(2)
2
3
(1)
4
(5)
5
(2)
6
(3)
7
(8)
8
(1)
9
10
11
12
(2)
13
(1)
14
(2)
15
16
(3)
17
(11)
18
(5)
19
(5)
20
(2)
21
(2)
22
(6)
23
(1)
24
25
(5)
26
27
(3)
28
(14)
29
(6)
30
31






Showing 2 results of 2

From: <lee...@us...> - 2009年05月12日 19:35:36
Revision: 7099
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7099&view=rev
Author: leejjoon
Date: 2009年05月12日 19:35:25 +0000 (2009年5月12日)
Log Message:
-----------
fixed a few bugs introduced in r7098(aspect for log-log plot).
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年05月12日 04:12:07 UTC (rev 7098)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年05月12日 19:35:25 UTC (rev 7099)
@@ -524,6 +524,8 @@
 self.set_label(label)
 self.set_figure(fig)
 
+ self.set_axes_locator(kwargs.get("axes_locator", None))
+
 # this call may differ for non-sep axes, eg polar
 self._init_axis()
 
@@ -548,7 +550,6 @@
 self.set_navigate(True)
 self.set_navigate_mode(None)
 
- self._axes_locator = None
 
 if xscale:
 self.set_xscale(xscale)
@@ -1085,7 +1086,7 @@
 raise ValueError('argument must be among %s' %
 ', '.join(mtransforms.BBox.coefs.keys()))
 
- def get_data_ratio(self, mode="linear"):
+ def get_data_ratio(self):
 """
 Returns the aspect ratio of the raw data.
 
@@ -1095,16 +1096,26 @@
 xmin,xmax = self.get_xbound()
 ymin,ymax = self.get_ybound()
 
- if mode == "log":
- xsize = max(math.fabs(math.log10(xmax)-math.log10(xmin)), 1e-30)
- ysize = max(math.fabs(math.log10(ymax)-math.log10(ymin)), 1e-30)
- else:
- xsize = max(math.fabs(xmax-xmin), 1e-30)
- ysize = max(math.fabs(ymax-ymin), 1e-30)
+ xsize = max(math.fabs(xmax-xmin), 1e-30)
+ ysize = max(math.fabs(ymax-ymin), 1e-30)
 
 return ysize/xsize
 
 
+ def get_data_ratio_log(self):
+ """
+ Returns the aspect ratio of the raw data in log scale.
+ Will be used when both axis scales are in log.
+ """
+ xmin,xmax = self.get_xbound()
+ ymin,ymax = self.get_ybound()
+
+ xsize = max(math.fabs(math.log10(xmax)-math.log10(xmin)), 1e-30)
+ ysize = max(math.fabs(math.log10(ymax)-math.log10(ymin)), 1e-30)
+
+ return ysize/xsize
+
+
 def apply_aspect(self, position=None):
 '''
 Use :meth:`_aspect` and :meth:`_adjustable` to modify the
@@ -1121,11 +1132,14 @@
 aspect_scale_mode = "linear"
 elif xscale == "log" and yscale == "log":
 aspect_scale_mode = "log"
- else:
+ elif (xscale == "linear" and yscale == "log") or \
+ (xscale == "log" and yscale == "linear"):
 warnings.warn(
 'aspect is not supported for Axes with xscale=%s, yscale=%s' \
 % (xscale, yscale))
 aspect = "auto"
+ else: # some custom projections have their own scales.
+ pass
 
 if aspect == 'auto':
 self.set_position( position , which='active')
@@ -1147,7 +1161,10 @@
 figW,figH = self.get_figure().get_size_inches()
 fig_aspect = figH/figW
 if self._adjustable == 'box':
- box_aspect = A * self.get_data_ratio(mode=aspect_scale_mode)
+ if aspect_scale_mode == "log":
+ box_aspect = A * self.get_data_ratio_log()
+ else:
+ box_aspect = A * self.get_data_ratio()
 pb = position.frozen()
 pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
 self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2009年05月12日 04:12:11
Revision: 7098
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7098&view=rev
Author: leejjoon
Date: 2009年05月12日 04:12:07 +0000 (2009年5月12日)
Log Message:
-----------
aspect for log-log plot
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/axes.py
Added Paths:
-----------
 trunk/matplotlib/examples/pylab_examples/aspect_loglog.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2009年05月08日 19:04:34 UTC (rev 7097)
+++ trunk/matplotlib/CHANGELOG	2009年05月12日 04:12:07 UTC (rev 7098)
@@ -1,4 +1,6 @@
 ======================================================================
+2009年05月11日 aspect=1 in log-log plot gives square decades.
+
 2009年05月08日 clabel takes new kwarg, rightside_up; if False, labels
 will not be flipped to keep them rightside-up. This
 allows the use of clabel to make streamfunction arrows,
Added: trunk/matplotlib/examples/pylab_examples/aspect_loglog.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/aspect_loglog.py	 (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/aspect_loglog.py	2009年05月12日 04:12:07 UTC (rev 7098)
@@ -0,0 +1,22 @@
+import matplotlib.pyplot as plt
+
+ax1 = plt.subplot(121)
+ax1.set_xscale("log")
+ax1.set_yscale("log")
+ax1.set_xlim(1e1, 1e3)
+ax1.set_ylim(1e2, 1e3)
+ax1.set_aspect(1)
+ax1.set_title("adjustable = box")
+
+ax2 = plt.subplot(122)
+ax2.set_xscale("log")
+ax2.set_yscale("log")
+ax2.set_adjustable("datalim")
+ax2.plot([1,3, 10], [1, 9, 100], "o-")
+ax2.set_xlim(1e-1, 1e2)
+ax2.set_ylim(1e-1, 1e3)
+ax2.set_aspect(1)
+ax2.set_title("adjustable = datalim")
+
+plt.draw()
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年05月08日 19:04:34 UTC (rev 7097)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年05月12日 04:12:07 UTC (rev 7098)
@@ -1085,7 +1085,7 @@
 raise ValueError('argument must be among %s' %
 ', '.join(mtransforms.BBox.coefs.keys()))
 
- def get_data_ratio(self):
+ def get_data_ratio(self, mode="linear"):
 """
 Returns the aspect ratio of the raw data.
 
@@ -1093,11 +1093,18 @@
 types.
 """
 xmin,xmax = self.get_xbound()
- xsize = max(math.fabs(xmax-xmin), 1e-30)
 ymin,ymax = self.get_ybound()
- ysize = max(math.fabs(ymax-ymin), 1e-30)
+
+ if mode == "log":
+ xsize = max(math.fabs(math.log10(xmax)-math.log10(xmin)), 1e-30)
+ ysize = max(math.fabs(math.log10(ymax)-math.log10(ymin)), 1e-30)
+ else:
+ xsize = max(math.fabs(xmax-xmin), 1e-30)
+ ysize = max(math.fabs(ymax-ymin), 1e-30)
+
 return ysize/xsize
 
+
 def apply_aspect(self, position=None):
 '''
 Use :meth:`_aspect` and :meth:`_adjustable` to modify the
@@ -1106,7 +1113,20 @@
 if position is None:
 position = self.get_position(original=True)
 
+
 aspect = self.get_aspect()
+
+ xscale, yscale = self.get_xscale(), self.get_yscale()
+ if xscale == "linear" and yscale == "linear":
+ aspect_scale_mode = "linear"
+ elif xscale == "log" and yscale == "log":
+ aspect_scale_mode = "log"
+ else:
+ warnings.warn(
+ 'aspect is not supported for Axes with xscale=%s, yscale=%s' \
+ % (xscale, yscale))
+ aspect = "auto"
+
 if aspect == 'auto':
 self.set_position( position , which='active')
 return
@@ -1127,7 +1147,7 @@
 figW,figH = self.get_figure().get_size_inches()
 fig_aspect = figH/figW
 if self._adjustable == 'box':
- box_aspect = A * self.get_data_ratio()
+ box_aspect = A * self.get_data_ratio(mode=aspect_scale_mode)
 pb = position.frozen()
 pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
 self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
@@ -1137,11 +1157,18 @@
 # by prior use of 'box'
 self.set_position(position, which='active')
 
+
 xmin,xmax = self.get_xbound()
+ ymin,ymax = self.get_ybound()
+
+ if aspect_scale_mode == "log":
+ xmin, xmax = math.log10(xmin), math.log10(xmax)
+ ymin, ymax = math.log10(ymin), math.log10(ymax)
+
 xsize = max(math.fabs(xmax-xmin), 1e-30)
- ymin,ymax = self.get_ybound()
 ysize = max(math.fabs(ymax-ymin), 1e-30)
 
+
 l,b,w,h = position.bounds
 box_aspect = fig_aspect * (h/w)
 data_ratio = box_aspect / A
@@ -1152,9 +1179,18 @@
 if abs(y_expander) < 0.005:
 #print 'good enough already'
 return
- dL = self.dataLim
- xr = 1.05 * dL.width
- yr = 1.05 * dL.height
+
+ if aspect_scale_mode == "log":
+ dL = self.dataLim
+ dL_width = math.log10(dL.x1) - math.log10(dL.x0)
+ dL_height = math.log10(dL.y1) - math.log10(dL.y0)
+ xr = 1.05 * dL_width
+ yr = 1.05 * dL_height
+ else:
+ dL = self.dataLim
+ xr = 1.05 * dL.width
+ yr = 1.05 * dL.height
+
 xmarg = xsize - xr
 ymarg = ysize - yr
 Ysize = data_ratio * xsize
@@ -1189,14 +1225,20 @@
 yc = 0.5*(ymin+ymax)
 y0 = yc - Ysize/2.0
 y1 = yc + Ysize/2.0
- self.set_ybound((y0, y1))
+ if aspect_scale_mode == "log":
+ self.set_ybound((10.**y0, 10.**y1))
+ else:
+ self.set_ybound((y0, y1))
 #print 'New y0, y1:', y0, y1
 #print 'New ysize, ysize/xsize', y1-y0, (y1-y0)/xsize
 else:
 xc = 0.5*(xmin+xmax)
 x0 = xc - Xsize/2.0
 x1 = xc + Xsize/2.0
- self.set_xbound((x0, x1))
+ if aspect_scale_mode == "log":
+ self.set_xbound((10.**x0, 10.**x1))
+ else:
+ self.set_xbound((x0, x1))
 #print 'New x0, x1:', x0, x1
 #print 'New xsize, ysize/xsize', x1-x0, ysize/(x1-x0)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 2 results of 2

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 によって変換されたページ (->オリジナル) /