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
I have some suggestions for fixing the frequency and julian_day plots created for the historical data using the PlotData module.
The frequency plot had overlapping year labels. The julian_day plot did not show any data for me, I think this is related to the use of seaborn.barplot but not entirely sure what the issue was. The julian_day plot also did not fit into the plot correctly, with y-labels cut off.
Change for frequency plot (apologies, I can't seem to get the code indentation to behave for the first line):
class PlotFrequency(PlotData):
def plotFrequency(self, years, frequency):
"""
Plot annual count of events within the domain.
TODO: Automatically adjust the x-tickmarks to be spaced
nicely (i.e. no overlap of labels).
Offer option of drawing the mean value (using
`axes.axhline`) or a linear trend line.
"""
"""
Bar plot, with added trend line or mean line
:param x: `numpy.ndarray` of x-values.
:param y: `numpy.ndarray` of y-values.
:param str name: Name of the parameter, which will be used
in the filename.
:param list labels: A list of the x- and y-axis labels to apply.
"""
labels = ["Year", "Number"]
fig, ax = plt.subplots(1, 1)
sns.barplot(years.astype(int), frequency, ax=ax)
ax.set_xlabel(labels[0])
ax.set_ylabel(labels[1])
for label in ax.get_xticklabels():
if np.int(label.get_text()) % 10 == 0: # every 10th label is kept
label.set_visible(True)
else:
label.set_visible(False)
ax.axhline(np.mean(frequency))
sns.despine()
fig.tight_layout()
self.savefig("frequency")
Resulting plot:
Update to julian_day plot (apologies, I can't seem to get the code indentation to behave for the first line):
class PlotDays(PlotData):
def plotJulianDays(self, julianDayObs, julianDayGenesis):
"""
Plot bar graphs of the number of TC observations per day of year
and genesis events per day of year.
TODO: Format the tick marks to represent monthly intervals.
Add a KDE over both bar plots, remembering this is cyclic
data (so KDE[-1] ~ KDE[0]).
"""
dateLocator = mdates.MonthLocator(bymonthday=15, interval=1)
dateFormat = mdates.DateFormatter("%b")
dates = mdates.num2date(julianDayObs[:, 0])
with plt.rc_context(dict(sns.axes_style(rc={'patch.edgecolor': "white",'patch.force_edgecolor': True}), **sns.plotting_context(rc={'patch.linewidth':.25}))):
f, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
sns.barplot(julianDayObs[:, 0], julianDayObs[:, 1], ax=ax1)
ax1.set_xlim((1, 365))
ax1.set_ylabel('Observations')
sns.barplot(julianDayGenesis[:, 0], julianDayGenesis[:, 1], ax=ax2)
ax2.set_xlim((1, 365))
ax2.set_xlabel('Month')
ax2.set_ylabel('Genesis events')
ax2.xaxis.set_major_locator(MONTH_LOCATOR)
ax2.xaxis.set_major_formatter(MONTH_FORMATTER)
sns.despine()
f.tight_layout()
self.savefig("julian_day")
Resulting plot:
The text was updated successfully, but these errors were encountered:
I have some suggestions for fixing the frequency and julian_day plots created for the historical data using the PlotData module.
The frequency plot had overlapping year labels. The julian_day plot did not show any data for me, I think this is related to the use of seaborn.barplot but not entirely sure what the issue was. The julian_day plot also did not fit into the plot correctly, with y-labels cut off.
Change for frequency plot (apologies, I can't seem to get the code indentation to behave for the first line):
class PlotFrequency(PlotData):
Resulting plot:
Update to julian_day plot (apologies, I can't seem to get the code indentation to behave for the first line):
class PlotDays(PlotData):
Resulting plot:
The text was updated successfully, but these errors were encountered: