georgebv / pyextremes

Extreme Value Analysis (EVA) in Python
https://georgebv.github.io/pyextremes/
MIT License
240 stars 47 forks source link

change visuals of the plot #13

Closed Goddysen closed 3 years ago

Goddysen commented 3 years ago

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

georgebv commented 3 years ago

@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:

https://github.com/georgebv/pyextremes/blob/662a9bf68cfd66a309f459f1f4ca433f2e712f95/src/pyextremes/eva.py#L1409-L1435

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.

Goddysen commented 3 years ago

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

Goddysen commented 3 years ago

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

georgebv commented 3 years ago

@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].