You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Howdy...
I was trying to make a single station time series of sky condition using StationPlot. I get an error ('invalid type promotion') when I send a Pandas date index for the x-axis values. I emailed with Ryan and advised me to use date2num, which works flawlessly. He mentioned I should send some code for a possible bug fix.
Here's some sample code:
importnumpyasnpimportdateutilimportpandasaspdimportmatplotlib.pyplotaspltfrommatplotlib.tickerimportFuncFormatterimportmatplotlib.datesasmdatesimportmatplotlib.tickerastickerimportmatplotlib.datesasdatesfrommetpy.calcimportreduce_point_densityfrommetpy.calcimportwind_componentsfrommetpy.cbookimportget_test_datafrommetpy.plotsimportadd_metpy_logo, current_weather, sky_cover, StationPlot, wx_code_mapfrommetpy.unitsimportunitsrng=pd.date_range('12/1/2017', periods=5, freq='D')
sc= [1,2,3,4,5]
ts=pd.Series(sc, index=rng)
fig, ax=plt.subplots()
y=np.ones(len(ts.index))
# This does NOT work:x=ts.index# metpy does not like datesstationplot=StationPlot(ax, x , y, fontsize=12)
stationplot.plot_symbol('C', ts , sky_cover)
# This works! :#x= dates.date2num(ts.index) # works! ... Thank you Ryan!#stationplot = StationPlot(ax, x , y, fontsize=12)#stationplot.plot_symbol('C', ts , sky_cover)ax.xaxis.set_major_locator(mdates.DayLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%-d'))
plt.show()
Thank you!!
Joe
The text was updated successfully, but these errors were encountered:
@dopplershift, how do you imagine this being handled? Is there a way to force any array to work here? Not sure if any others would give errors if we just handled the pandas case here. At any rate, the issue is within plot_text for this case, but the type conversion could likely be handled in the init function.
Howdy...
I was trying to make a single station time series of sky condition using StationPlot. I get an error ('invalid type promotion') when I send a Pandas date index for the x-axis values. I emailed with Ryan and advised me to use date2num, which works flawlessly. He mentioned I should send some code for a possible bug fix.
Here's some sample code:
Thank you!!
Joe
The text was updated successfully, but these errors were encountered: