Using ax parameter in screeplot

Hi! Sorry if this question is stupid/weirdly formulated; I am quite new to the Pyleoclim package and to Python in general. I am trying to perform SSA on a dataset using Pyleoclim and the tutorial at [Singular Spectrum Analysis with Pyleoclim — Pyleoclim Tutorials]; however, I’m having a bit of trouble when generating my Scree plot. Apart from my first eigenvalue (representing the trend), the rest are tightly clustered towards the bottom of the plot, so it’s quite hard to tell them apart. For this reason, I’d like to have a logarithmic scale on the y-axis. I know that this can be accomplished using the ‘semiology’ function from Matplotlib, and from what I understand I should be able to use an axis object from Matplotlib in the Pyleoclim Screeplot function by way of the ‘ax’ parameter. However, I don’t quite understand how to accomplish this. Could somebody here perhaps help me out?

Hi Erik,

Not a weird question at all! I think the approach you’re considering isn’t quite the right way to go about it. It looks like semilogy is plotting level function (that is it’s used to generate new plots). What it sounds like you want to do really is just re-scale an existing figure. The best way I’ve found to do this is to capture the output of the screeplot function (which is a matplotlib.pyplot figure and axis object) and rescale the axis object. Here’s a minimal code snippet example (assuming your pyleo.Series object is called “series”):

ssa = series.ssa()
fig,ax = ssa.screeplot()
ax.set_yscale(“log”)

I think that should do the trick. If not let me know and we can troubleshoot further!

Heaps of thanks alex_james; this worked perfectly! Follow-up question: would you know if it is possible to change the size of the data points, to better be able to tell them apart? With the default settings some of them seem to ‘mesh together’.

No worries, glad it worked!

Unfortunately at the moment it doesn’t look like it’s possible to modify the size of the markers. This is really an oversight on our part, we should include optional key word arguments for the plotting functions. I’d suggest opening an issue about it on the Pyleoclim Github (here), describing what you’d like to do. We’re normally pretty quick about implementing stuff like this when users ask for it.

Thanks @alex_james for being on top of it. I tried this with the SOI series and noticed that the yticks were a little wonky. When switching to log scale, they might need to be adjusted manually, like so:

import pyleoclim as pyleo
ts = pyleo.utils.load_dataset('SOI')
soi_ssa = ts.ssa()
fig, ax = soi_ssa.screeplot()
ax.set_yscale('log') 
ax.set_yticks([.1, 1, 10]) 

Good point about marker size. That should be an easy fix once you open an issue.