1

I'm trying to plot a dash-line in a plot using:

ax.plot([dt.datetime(2012,01,27,18,19),
         dt.datetime(2012,01,27,18,19)], [0, 1300], 'k--', lw=2)

It works fine when I use linnear scale but when I define a log scale

ax.set_yscale('log')

the line dont appear

1 Answer 1

4

It won't show because you have the number 0 on the y axis, change it to something positive, e.g. 1:

import matplotlib.pyplot as plt
import datetime as dt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([dt.datetime(2012,01,27,18,19),
     dt.datetime(2012,01,27,18,19)], [1, 1300], 'k--', lw=2)
ax.set_yscale('log')
plt.show()

Explanation:

log(0) is not defined. Numpy returns -inf (which has some logic behind it), but if you try to draw a point with inf or nan value, it is not going to be drawn. With plots made of line segments this means that two line segments are going to disappear. Now you tried to draw a line between an existing point and a non-existing point. (You can verify this by changing the style to 'o'.)

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.