Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a list of line styles in matplotlib?

I'm writing a script that will do some plotting. I want it to plot several data series, each with its unique line style (not color). I can easily iterate through a list, but is there such a list already available in python?

like image 313
Yotam Avatar asked Nov 13 '12 11:11

Yotam


People also ask

Which of the following is not a valid style in matplotlib?

question. Answer: Option "c: line()" is the correct answer. line() is not a valid plotting function of pyplot.

How many types of graphs are there in matplotlib?

Matplotlib in Python is a package that is used for displaying the 2D graphics. The Matplotlib can be used in python scripts, shell, web application servers and other GUI toolkits. Python provides different types of plots such as Bar Graph, Histogram, Scatterplot, Area plot, Pie plot for viewing the data.

What are line styles?

A line style identifies a particular line of text in the report file that contains information to be extracted. Each line style must be defined such that Extract Editor can identify the same line throughout the report file.


2 Answers

According to the doc you could find them by doing this :

from matplotlib import lines lines.lineStyles.keys() >>> ['', ' ', 'None', '--', '-.', '-', ':'] 

You can do the same with markers

EDIT: In the latest versions, there are still the same styles, but you can vary the space between dots/lines.

like image 54
Cédric Julien Avatar answered Sep 22 '22 15:09

Cédric Julien


plot documentation

http://matplotlib.org/1.5.3/api/pyplot_api.html#matplotlib.pyplot.plot has a list of line + marker styles:

character description '-'       solid line style '--'      dashed line style '-.'      dash-dot line style ':'       dotted line style '.'       point marker ','       pixel marker 'o'       circle marker 'v'       triangle_down marker '^'       triangle_up marker '<'       triangle_left marker '>'       triangle_right marker '1'       tri_down marker '2'       tri_up marker '3'       tri_left marker '4'       tri_right marker 's'       square marker 'p'       pentagon marker '*'       star marker 'h'       hexagon1 marker 'H'       hexagon2 marker '+'       plus marker 'x'       x marker 'D'       diamond marker 'd'       thin_diamond marker '|'       vline marker '_'       hline marker 

Since this is part of the pyplot.plot docstring, you can also see it from the terminal with:

import matplotlib.pyplot as plt help(plt.plot)