0

I currently plot a graph with matplotlib.pyplot. I have some data and the data never reaches zero. Sometimes it's very close with 1e-19 or so but it never reaches it. Now I am plotting the data with log scale:

ax = fig.add_axes([0,0,1,1])
ax.plot(x,ye15, label='1e15')
ax.plot(x,ye16, label='1e16')
ax.plot(x,ye17, label='1e17')
ax.plot(x,ye18, label='1e18')
ax.plot(x,ye19, label='1e19', marker='o')


ax.set_xlabel('Voltage in V')
ax.set_ylabel('Current in mA')
ax.set_title('IV')
legend = ax.legend()
ax.set_yscale("log")
ax.set_ylim(1e-21, 1e-7)
fig

The problem is now I get weird vertical lines so matplotlib doesn't correctly connect the points. What should I do to fix this?

Without the log scale and without a zoom into the data the result looks like this:enter image description here After the log scale and zoom has been applied it looks like this enter image description here

The Data between -0.5 and -0.2 looks like this: enter image description here

Thanks Kevin

Result: I have some negative values and they lead to the nan values in the log scale. Solution: Make all numbers positive

KevinK
  • 13
  • 2
  • @Mr.T The data as no NaN or zero values. The result without the line is shown in my question now. – KevinK Jan 26 '21 at 11:49
  • @Mr.T I have now added the used data in the region of -0.21 to -0.49 of the 1e19 slope – KevinK Jan 26 '21 at 13:25
  • Hi and welcome to SO! Could you please edit your question to share your sample data and code in a way that we can just copy-paste it and get something like the figure you show? There are several ways to do this as illustrated in the examples [here](https://stackoverflow.com/a/65290580/14148248), [here](https://stackoverflow.com/a/66198319/14148248), [here](https://stackoverflow.com/q/20109391/14148248) and [here](https://stackoverflow.com/q/52413246/14148248). We can help you find a solution if you help us reproduce the problem more easily. – Patrick FitzGerald Feb 15 '21 at 09:58
  • I will do so next time the answer to this question is that I have some negative values and log of negative values give a nan result – KevinK Feb 16 '21 at 10:13

0 Answers0