-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'matplotlib' option no longer working in utils.plotting.set_style() #513
Comments
Do you remember when you last used this option? Trying to roll back but it would help to have a date |
@khider Looks like you already found where it was removed, but in case it's still useful I was previously using a version of the package I think I downloaded in early 2021. |
Sorry, it has been too long and I can't remember exactly why I removed that. It's probably that it's not working as expected in certain cases at that time, and I did that to avoid confusion. Please feel free to put it back and have a test to see if it works. Things could be different now. |
Ok, I reinstated matplotlib on my version of the code. Two concerns:
Second concern: The stack plot doesn't work with this style: I could put a warning when the style is selected that some functionalities may no longer work and push the change. Any suggestions @CommonClimate and @fzhu2e ? |
Sorry to intrude but would it be possible to just leave the rc params as
they are by passing a blank style_dict instead of restoring to default
rcparams? I did a quick test and it looks like
mpl.rcParams.update(plt.rcParamsDefault) is what messes up the automatic
display of plots. But I guess this would not fix the problem with stackplot
probably.
See my minimum reproducible example below, which does not not mess up
automatic display of plots:
import matplotlib as mpl
import matplotlib.pyplot as plt
def set_style(style='matplotlib',font_scale=1,dpi=400):
font_dict = {
'font.size': 10,
'axes.labelsize': 11,
'axes.titlesize': 12,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'legend.fontsize': 9,
}
style_dict = {}
if 'matplotlib' in style:
style_dict.update({
})
figure_dict = {
'savefig.dpi': dpi,
}
font_dict.update({k: v * font_scale for k, v in font_dict.items()})
for d in [style_dict, font_dict, figure_dict]:
mpl.rcParams.update(d)
set_style()
data=range(0,100,10)
plt.plot(data,data)
…_________________________________________________________________________
If I replace the following:
if 'matplotlib' in style:
style_dict.update({
})
with the original version:
if 'matplotlib' in style:
mpl.rcParams.update(plt.rcParamsDefault)
this leads to the problem with the plot not displaying without calling
plt.show().
Best,
Eve
On Wed, Feb 14, 2024 at 1:15 PM Deborah Khider ***@***.***> wrote:
Ok, I reinstated matplotlib on my version of the code. Two concerns:
1. By default, Matplotlib doesn't show plots anymore. So one needs to
do the following:
import pyleoclim as pyleo
import matplotlib.pyplot as plt
pyleo.set_style('matplotlib')
ts = pyleo.utils.load_dataset('LR04')
fig,ax=ts.plot()
plt.show(fig)
Second concern: The stack plot doesn't work with this style:
image.png (view on web)
<https://github.com/LinkedEarth/Pyleoclim_util/assets/11758571/c583ed0d-5ead-45c0-a4c2-18e444eb1dda>
I could put a warning when the style is selected that some functionalities
may no longer work and push the change. Any suggestions @CommonClimate
<https://github.com/CommonClimate> and @fzhu2e <https://github.com/fzhu2e>
?
—
Reply to this email directly, view it on GitHub
<#513 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKCY736FYHHCW52WLUCJYXLYTUSO3AVCNFSM6AAAAABC3CWGKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGYYTIOBRGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
thank you! |
Yes, I agree a warning is needed. stackplot is a unique application and the style is hard-coded. |
Bug description: I prefer to avoid changes to default matplotlib formats that occur when importing pyleoclim by using the 'matplotlib' option in pyleo.utils.plotting.set_style(), but since updating to a newer version of the package in the past week, this option no longer seems available (although it is still listed in the documentation).
To reproduce:
from pyleoclim import utils
utils.plotting.set_style(style='matplotlib')
Which returns the error message:
ValueError: Style [matplotlib] not availabel!
Choosing other style options like 'journal' or 'web' runs without errors and seems to work as expected.
Looking at the source code for the utils.plotting.set_style function, it appears that the 'matplotlib' style option is not defined anywhere, whereas the other options (journal, web, spines, etc.) are defined. Restoring this option so it's possible to import pyleoclim and keep current matplotlib settings without having to reset rcparams would be helpful.
Edit to add: I'm using version 0.13.0
The text was updated successfully, but these errors were encountered: