georgebv/pyextremes

change visuals of the plot

Goddysen opened this issue · 4 comments

THE CODE ARE LISTED AS FOLLOWS:

fig, ax = plot_extremes(
    ts=series,
    extremes=extremes,
    extremes_method="BM",
    extremes_type="high",
    block_size="365.2425D",
    figsize=(10, 4),
    ax={"lines.color":"green","font.size": 12,"axes.linewidth": 0.8 }
)

THE ERROR ARE LISTED:
TypeError: invalid type in <class 'dict'> for the 'ax' argument, must be matplotlib Axes object

what is the right form for the argument "ax" and how to change it

Thanks

@Goddysen this is not a bug, the ax argument should be used only when you have an existing matplotlib Axes object onto which you want to draw the plot. Example in EVA:

fig = plt.figure(figsize=figsize, dpi=96)
# Create gridspec
gs = matplotlib.gridspec.GridSpec(
nrows=2,
ncols=2,
wspace=0.3,
hspace=0.3,
width_ratios=[1, 1],
height_ratios=[1, 1],
)
# Create axes
ax_rv = fig.add_subplot(gs[0, 0])
ax_pdf = fig.add_subplot(gs[0, 1])
ax_qq = fig.add_subplot(gs[1, 0])
ax_pp = fig.add_subplot(gs[1, 1])
# Plot return values
self.plot_return_values(
return_period=return_period,
return_period_size=return_period_size,
alpha=alpha,
plotting_position=plotting_position,
ax=ax_rv,
**kwargs,
)

For what you want you shouldn't use the ax argument and instead use the ax object you create and edit its children. You can do something like this:

fig, ax = plot_extremes(
    ts=series,
    extremes=extremes,
    extremes_method="BM",
    extremes_type="high",
    block_size="365.2425D",
    figsize=(10, 4),
)
for line in ax.get_lines():
    line.set_color("green")

I suggest you read this stackoverflow post and matplotlib axes documentation.

I got your point! Thank you very much for your answer!

about the plot_corner() function

HELLOW!

THE CODE USED IN JUPYTER ARE LISTED AS FOLLOWS:

fig_4, ax_4 = plot_corner(
trace=model_1.trace,
trace_map=model_1.trace_map,
burn_in=50,
labels=[r"Shape, $\xi$", r"Location, $\mu$", r"Scale, $\sigma$"],
levels=5,
)

ax_4[0][0] #IT DISPLAY xlabel='Shape, ylabel='Scale,
ax_4[1][0] #IT DISPLAY xlabel='Shape, ylabel='Scale, AGAIN
ax_4[2][0] #IT DISPLAY xlabel='Shape,, ylabel='Scale AGAIN

WHAT'S THE ORDER OF THESE PLOT (AXES) IN LIST?

Q2IU$782 M@C%{SU0S Q8EG

Thanks!Looking forward to your answer

@Goddysen thank you for pointing this out, this is a genuine bug. Was easy to fix. New pyextremes version should appear on PyPI today and conda tomorrow.

Once you get new version (2.2.4) the axes are located left-to-right and top-to-bottom: e.g. left upper corner is [0][0] and right bottom corner is [2][2] or [-1][-1].