I need to present a logarithmic scale scatter plot of the following array:
x =[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 39, 42, 44, 48]
y = [2.43310035e-01, 1.98717530e-01, 1.49977138e-01, 1.14921506e-01,
8.24242820e-02, 5.90611187e-02, 4.29377055e-02, 3.07771028e-02,
2.14144185e-02, 1.56552790e-02, 1.08977290e-02, 8.31754741e-03,
5.73736582e-03, 3.95192371e-03, 2.91767370e-03, 2.46042633e-03,
1.77455527e-03, 1.16489211e-03, 7.94739478e-04, 7.51192109e-04,
5.22568424e-04, 2.61284212e-04, 2.39510528e-04, 1.41528948e-04,
1.74189475e-04, 1.30642106e-04, 1.41528948e-04, 1.19755264e-04,
6.53210530e-05, 3.26605265e-05, 2.17736843e-05, 2.17736843e-05,
7.62078951e-05, 2.17736843e-05, 2.17736843e-05, 0.00000000e+00,
0.00000000e+00, 2.17736843e-05, 2.17736843e-05, 0.00000000e+00,
0.00000000e+00]
I initially do the plot.scatter
using the following statement:
plt.scatter(x,y)
The image I get is this:
I want to use logarithmic scale on the Y axis, but if I use the instruction plt.yscale('log')
I don't get all the points on the graph, I only get 4 points.
Can somebody help me? What do I have to do so that it shows me all the data, using logarithmic scale on the Y axis?
scatter
apparently it has problems automatically autoscaling the graph when there are very small values ( issue report on GitHub ). You have several alternatives:You can use
matplotlib.pyplot.semilogy
instead ofscatter
:Another option is to use
matplotlib.pyplot.plot
:If you want to use
matplotlib.pyplot.scatter
, for whatever reason, you can manually specify the axis limitsy
:In all cases we get: