JVarhol
JVarhol

Reputation: 626

Python- Connecting Lines with plot_date in Matplotlib

I am using matplotlib to graph out some data in which takes time over a time, therefore I have to use plot_date in order to plot my lines. But for some reason Plot_Date and Plot have completely different formatting as far as connecting lines.

Here is what It looks like when using plot(x,y) Pic1

Using plot(x,y,'bo') or plot_date(x,y,'bo') Pic2

Plot_date(x,y) looks like that ^^ too.

and using plot_date(x,y,'bo-') Pic3

How do I make it so that the result of plot_date looks like the first picture? I have looked all over the Matplotlib website and couldn't find anything.

Thanks in advance

Upvotes: 11

Views: 15311

Answers (2)

Vaclav Vlcek
Vaclav Vlcek

Reputation: 366

If you want to have the markers connected with the lines, you can also use

plt.plot_date(y,x,linestyle='solid')

So the complete code for the beginners would be:

from matplotlib import pyplot as plt
plt.plot_date(y,x,linestyle='solid')
plt.show()

Do not forget you need to have matplotlib installed first. For that you need to open command line and write:

pip install matplotlib

Upvotes: 1

JVarhol
JVarhol

Reputation: 626

Upon further investigation I found that in order to display a solid line without dots, I needed to use the line style 'b-', making the code plot_date(x,y,'b-').

Upvotes: 24

Related Questions