Plotting basic raman spectra #689
-
Hi, I'm new to spectrochempy and would love some help plotting my raman data. There are there different lines (defined in my y dimension). I'd like to plot them, create a legend with labels I create (and not the self-generated ones) and axis limits, and exclude any data points that exceed a certain value. Any help would be very much appreciated. I'm not sure why I keep getting stuck. I tried using the plot_multiple method, but I want all the lines to be solid (and not dashed or dotted). I tried just using the data.plot() method but I can't figure out how to remove data points above a certain value in my y axis (or my "data" dimension). Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
For plot multiple you can use the new version of this function (not yet released): To use it you need to use conda or mamba and install the dev version
If you send me some sample spectra, I can write a small exemple to show you how to do the plotting you want (this could be introduced in our documentation as well). To do advanced plotting, it may be sometimes necessary to use directly the matplotlib library. |
Beta Was this translation helpful? Give feedback.
-
", and exclude any data points that exceed a certain value". For this you could use masks. In a next post I will give you an example of code. |
Beta Was this translation helpful? Give feedback.
-
thank you!! I'll keep trying it out. I attached a sample txt file that I've been trying to work with. Thanks so much! |
Beta Was this translation helpful? Give feedback.
-
OK plot_multiple is now fixed. You can get the last DEV version, and here is a sample code on how you can proceed. import spectrochempy as scp
B1 = scp.read("ramandata/serie190214-1.txt")
# Basic plot
_ = B1.plot(cmap=None, lw=1)
# limit the x range
B2 = B1[:, 60.0:] # note the float number to specify that we use coordinates
# detrend
B3 = scp.detrend(B2)
_ = B3.plot(cmap=None)
# denoising
pca = scp.PCA(n_components=10)
pca.fit(B3)
B4 = pca.inverse_transform()
_ = B4.plot(cmap=None)
# take only some spectra (5)
B5 = B4[:5]
B5.plot(cmap=None)
# plot multiple with offset and labels
prefs = B5.preferences
prefs.figure.figsize = (8,6)
datasets = list(B5)
_ = scp.plot_multiple(datasets,
method="pen",
legend="best",
labels=["A", "B", "C", "D", "E"],
color = ["black", "red", "green", "blue", "violet"],
lw=[1, 2.5, 1, 1, 1], # line width
ls='-', # solid line
shift=1000, # vertical shift
) |
Beta Was this translation helpful? Give feedback.
In principle this is now solved : see #690 (comment).
I mark this discussion as answered for now.