matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

Log scale

Open ibmua opened this issue 6 years ago • 4 comments

Is there a way to use logarithmic scale for Y?

ibmua avatar Feb 26 '19 23:02 ibmua

Was also looking for this. Figured out a way to do this with a few changes to [matplotlibcpp.h], basically just copying the same things as what is done for [axis] and it works well. Add [ PyObject *s_python_function_yscale; ] to the struct [ struct _interpreter ] (around line 70). Add [ s_python_function_yscale = safe_import(pymod, "yscale"); ] to _interpreter() (around line 200). Then copy the function [ inline void axis(const std::string &) ] and make the name of the new function to be [yscale] and thats it. You can now use it by calling plt::yscale("log");. The same procedure works for [xscale].

HAWinther avatar Feb 13 '20 12:02 HAWinther

You could simply use semilogy, a thin wrapper around plot which additionally changes y-axis to log scaling:

image

zchenpds avatar Oct 29 '21 23:10 zchenpds

I am also looking for log log capabilities. Are there any features similar to matplotlib.pyplot's plt.xscale and plt.yscale?

ghost avatar Feb 15 '22 23:02 ghost

@colramos-amd is loglog(x, y) what you are looking for?

zchenpds avatar Feb 15 '22 23:02 zchenpds