Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita529004

Browse files
authored
Merge pull request#10639 from matplotlib/auto-backport-of-pr-10623
Backport PR#10623 on branch v2.2.x
2 parents7ccdefd +caefff7 commita529004

File tree

6 files changed

+61
-23
lines changed

6 files changed

+61
-23
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,39 +2189,17 @@ def bar(self, *args, **kwargs):
21892189
adjust_xlim=True
21902190
x=0
21912191

2192-
x,height,width,y,linewidth=np.broadcast_arrays(
2193-
# Make args iterable too.
2194-
np.atleast_1d(x),height,width,y,linewidth)
2195-
21962192
iforientation=='vertical':
21972193
self._process_unit_info(xdata=x,ydata=height,kwargs=kwargs)
21982194
iflog:
21992195
self.set_yscale('log',nonposy='clip')
2200-
2201-
tick_label_axis=self.xaxis
2202-
tick_label_position=x
22032196
eliforientation=='horizontal':
22042197
self._process_unit_info(xdata=width,ydata=y,kwargs=kwargs)
22052198
iflog:
22062199
self.set_xscale('log',nonposx='clip')
2207-
2208-
tick_label_axis=self.yaxis
2209-
tick_label_position=y
22102200
else:
22112201
raiseValueError('invalid orientation: %s'%orientation)
22122202

2213-
linewidth=itertools.cycle(np.atleast_1d(linewidth))
2214-
color=itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
2215-
# Fallback if color == "none".
2216-
itertools.repeat([0,0,0,0]))
2217-
ifedgecolorisNone:
2218-
edgecolor=itertools.repeat(None)
2219-
else:
2220-
edgecolor=itertools.chain(
2221-
itertools.cycle(mcolors.to_rgba_array(edgecolor)),
2222-
# Fallback if edgecolor == "none".
2223-
itertools.repeat([0,0,0,0]))
2224-
22252203
# lets do some conversions now since some types cannot be
22262204
# subtracted uniformly
22272205
ifself.xaxisisnotNone:
@@ -2236,6 +2214,30 @@ def bar(self, *args, **kwargs):
22362214
ifyerrisnotNone:
22372215
yerr=self.convert_yunits(yerr)
22382216

2217+
x,height,width,y,linewidth=np.broadcast_arrays(
2218+
# Make args iterable too.
2219+
np.atleast_1d(x),height,width,y,linewidth)
2220+
2221+
# Now that units have been converted, set the tick locations.
2222+
iforientation=='vertical':
2223+
tick_label_axis=self.xaxis
2224+
tick_label_position=x
2225+
eliforientation=='horizontal':
2226+
tick_label_axis=self.yaxis
2227+
tick_label_position=y
2228+
2229+
linewidth=itertools.cycle(np.atleast_1d(linewidth))
2230+
color=itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
2231+
# Fallback if color == "none".
2232+
itertools.repeat([0,0,0,0]))
2233+
ifedgecolorisNone:
2234+
edgecolor=itertools.repeat(None)
2235+
else:
2236+
edgecolor=itertools.chain(
2237+
itertools.cycle(mcolors.to_rgba_array(edgecolor)),
2238+
# Fallback if edgecolor == "none".
2239+
itertools.repeat([0,0,0,0]))
2240+
22392241
# We will now resolve the alignment and really have
22402242
# left, bottom, width, height vectors
22412243
ifalign=='center':

‎lib/matplotlib/testing/jpl_units/EpochConverter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def duration2float( value ):
101101
= RETURN VALUE
102102
- Returns the value parameter converted to floats.
103103
"""
104-
returnvalue.days()
104+
returnvalue.seconds()/86400.0
105105

106106
#------------------------------------------------------------------------
107107
@staticmethod

‎lib/matplotlib/testing/jpl_units/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def register():
6565

6666
mplU.registry[str ]=StrConverter()
6767
mplU.registry[Epoch ]=EpochConverter()
68+
mplU.registry[Duration ]=EpochConverter()
6869
mplU.registry[UnitDbl ]=UnitDblConverter()
6970

7071
#=======================================================================

‎lib/matplotlib/tests/test_units.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
frommatplotlib.testing.decoratorsimportimage_comparison
44
importmatplotlib.unitsasmunits
55
importnumpyasnp
6+
importdatetime
67

78
try:
89
# mock in python 3.3+
@@ -95,3 +96,37 @@ def test_plot_masked_units():
9596

9697
fig,ax=plt.subplots()
9798
ax.plot(data_masked_units)
99+
100+
101+
@image_comparison(baseline_images=['jpl_bar_units'],extensions=['png'],
102+
savefig_kwarg={'dpi':120},style='mpl20')
103+
deftest_jpl_bar_units():
104+
fromdatetimeimportdatetime
105+
importmatplotlib.testing.jpl_unitsasunits
106+
units.register()
107+
108+
day=units.Duration("ET",24.0*60.0*60.0)
109+
x= [0*units.km,1*units.km,2*units.km]
110+
w= [1*day,2*day,3*day]
111+
b=units.Epoch("ET",dt=datetime(2009,4,25))
112+
113+
fig,ax=plt.subplots()
114+
ax.bar(x,w,bottom=b)
115+
ax.set_ylim([b-1*day,b+w[-1]+1*day])
116+
117+
118+
@image_comparison(baseline_images=['jpl_barh_units'],extensions=['png'],
119+
savefig_kwarg={'dpi':120},style='mpl20')
120+
deftest_jpl_barh_units():
121+
fromdatetimeimportdatetime
122+
importmatplotlib.testing.jpl_unitsasunits
123+
units.register()
124+
125+
day=units.Duration("ET",24.0*60.0*60.0)
126+
x= [0*units.km,1*units.km,2*units.km]
127+
w= [1*day,2*day,3*day]
128+
b=units.Epoch("ET",dt=datetime(2009,4,25))
129+
130+
fig,ax=plt.subplots()
131+
ax.barh(x,w,left=b)
132+
ax.set_xlim([b-1*day,b+w[-1]+1*day])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp