Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I simply want to plot "a vs b" in a log-log scaled plot, but I get an error.

import matplotlib.pyplot as plt

a = [7255.151855, 231.589661, 9.365415, 0.55364, 1.5001, 0.006408, 0.001204, 0.000842]
b = [0.212399, 0.393191, 0.727874, 1.347436, 2.494368, 4.617561, 8.548006, 15.824027]

CyclesPerBlock = 219397
LoadAmplitude = 4990

a = [x*CyclesPerBlock for x in a]
b = [y*LoadAmplitude for y in b]

fig = plt.plot
fig.set_xscale("log")
fig.set_yscale("log")
fig.set_xlim(1e-3, 1e4)
fig.set_ylim(1e-1, 1e3)
fig.set_aspect(1)
fig.set_title("Calculation Results")

fig.plot(a, b, "o-")
plt.draw()
plt.show()
share|improve this question
    
You got an answer, but it is better to include the full traceback when posting your question. It is also best to post the minimum amount of code required to generate the issue. –  tcaswell May 23 '14 at 13:29

1 Answer 1

up vote 4 down vote accepted

You have to create the AxesSubplot object first, and then use it to plot:

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xscale("log")
ax.set_yscale("log")
ax.set_xlim(1e-3, 1e4) # <-- check this as pointed out by @tillsten
ax.set_ylim(1e-1, 1e3) # <--
ax.set_aspect(1)
ax.set_title("Calculation Results")

ax.plot(a, b, "o-")
share|improve this answer
1  
Also your xlim and ylim are wrong. –  tillsten May 23 '14 at 12:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.