Wikipedia

Search results

Friday, 27 August 2021

Graphs using matplotlib for pandas data frame

 import pandas as pd
import matplotlib.pyplot as plt

df=pd.DataFrame({"X":[0,2,4,6,8]})


df.plot(style=['r*-'])


#'r*-' is called formatting string

#Formating string syntax is ['marker''Line''Color']
# r   -->red color
# *   --> marker
#     - --> solid line

plt.show()




Formating string syntax is ['marker''Line''Color']

Marker
'.' 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
'8' octagon marker

's' square marker

'p' pentagon marker

'P' plus (filled) marker

'*' star marker

'h' hexagon1 marker

'H' hexagon2 marker

'+' plus marker

'x' x marker

'X' x (filled) marker

'D' diamond marker

'd' thin_diamond marker

'|' vline marker

'_' hline marker



Line Styles

character description
'-'                 solid line style

'--'                 dashed line style

'-.'              dash-dot line style

':'                 dotted line style



Colors

character color
'b'                blue

'g'                green

'r'               red

'c'              cyan

'm'            magenta

'y'              yellow

'k'              black

'w'                 white

No comments:

Post a Comment