1

I am trying to plot some data with a probability scale (Y-axis) and log scale (X-axis). Here is the code that I am currently using:

import matplotlib.pyplot as plt
import probscale

x = [0.25,0.28,0.3,0.35,0.4,0.45,0.5,0.58,0.65,0.7,0.8,1,1.3,1.6,2,2.5,3]
y = [0,0.577629967,1.155259933,1.680378085,2.485559251,3.920882198,4.98862244,
     10.13478033,18.32662349,23.15771048,33.81760896,47.43567303,70.13828111,
     82.74111675,94.78382636,98.09207072,100]

fig, ax = plt.subplots(figsize=(8, 6))
ax.set_yscale('prob')
ax.set_ylim(bottom=0.1, top=99.9)
ax.set_ylabel('Cumulative mass(%)')
ax.set_xscale('log')
ax.set_xlim(left=0.2, right=3.5)
ax.set_xlabel('Diameter')

plt.scatter(x,y)
plt.show()

And the picture below shows what I got by the code.
I wonder how to add a linear fitting to the current plot. Thank you!
Jerry

enter image description here

xiaosu
  • 51
  • 2
  • 2
    It looks like `probscale.probplot` can do this: https://matplotlib.org/mpl-probscale/tutorial/closer_look_at_viz.html#best-fit-lines – tmdavison Nov 19 '20 at 15:47
  • Yes but the probscale.probpolt function can not plot x,y data, it seems not able to assign the probability value to each data point of X. – xiaosu Nov 20 '20 at 02:55
  • I suppose you actually want to fit a sigmoid to your data, as e.g. [seen in this answer](https://stackoverflow.com/a/62215374/565489). This should then appear (nearly!) linear in this plot. – Asmus Nov 20 '20 at 09:30
  • Thanks Asmus, I am not going to fit a sigmoid to my data, I want to draw a fitted line based on the data points of the current plot which is very easy to be done with Origin. I want to implement the calculation method of this document. https://www.oecd.org/chemicalsafety/testing/34029468.pdf (page 18) Thank you! – xiaosu Nov 21 '20 at 15:37

0 Answers0