1

I produce the following loglog plot in Python: enter image description here

Data is here. I would like to add to this plot a series of straight line that starts and ends between these pair of data values:

[1.0, 0.05556],
[1.0, 1.0],
[1.0, 17.9996],
[1.0, 5831.9992]

In Matlab, you simply have to produce the loglog plot as above followed by the simple plot command using as input the pair of data points and both plots get combined into one. Is there a similar way in Python/Matplotlib? I tried using:

plt.loglog(main_data)
plt.plot(linspace_data)  # linspace_data is a linear interpolation between the data values above.

but no success... Basically, I want this plot (generated in Matlab): enter image description here

1 Answer 1

3

This is made much simpler in the O-O interface:

fig, ax = plt.subplots() # this is the only "plt" fxn you need 99% of the time
x = [2, 57]
y = [12, 112]
ax.plot(x, y, '-')
ax.set_yscale('log')
ax.set_xscale('log')

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the answer but linspace_data is a simple linear interpolation between two data points and the log scale "deforms" the linear line and hence I do not have straight lines.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.