Read and Export data¶
The functions in the previous tutorial make plotting pretty automatic, using matplotlib's standard style. But sometimes, you might just want to read the data without immediately plotting it—maybe to style it your own way or to convert it into a different format.
Customize spinplots¶
In the previous tutorial, we used read_nmr() and then .plot() to create a simple 13C NMR plot. By adding the option return_fig=True, you can return the figure object, which allows you to further customize the appearance of the spectrum as you like.
gly = read_nmr("../../data/1D/glycine/pdata/1")
fig, ax = gly.plot(xlim=(250, -20), return_fig=True)
ax.set_title("Customized plot")
ax.set_xlabel("13-Carbon NMR in ppm")
ax.lines[0].set_color("purple")
ax.lines[0].set_linewidth(2)
ax.lines[0].set_linestyle("-.")
fig.savefig("../../data/1D/customized_plot.png")
Export data to Pandas and CSV¶
A different option is to use the nmr_df function from spinplots.utils to get a Pandas DataFrame. This way, you can manipulate the data however you like before plotting.