agneau1236
agneau1236

Reputation: 9

Hide lines from a multiple line plot

I have a dataframe with 12 columns and 30 rows (only the first 5 rows are shown here):

           0         1         2         3         4         5         6         7         8         9        10        11
0                                                                                                                         
10  0.420000  0.724000  0.552000  0.316000  0.176000  0.320000  0.228000  0.552000  0.476000  0.468000  0.560000  0.332000
20  0.387097  0.701613  0.516129  0.338710  0.177419  0.346774  0.217742  0.443548  0.483871  0.435484  0.516129  0.330645
30  0.353659  0.731707  0.365854  0.280488  0.158537  0.243902  0.231707  0.451220  0.524390  0.414634  0.451220  0.329268
40  0.377049  0.557377  0.311475  0.213115  0.213115  0.262295  0.262295  0.459016  0.540984  0.475410  0.377049  0.262295
50  0.285714  0.673469  0.183673  0.183673  0.163265  0.285714  0.204082  0.387755  0.489796  0.367347  0.306122  0.244898  

I would like to plot a dot plot with rows indices as the x-axis columns values as the y-axis (ie. 12 dots on each x).

I have tried the following:

df.plot()

and I get this plot multiple line plots I get

I would like to show only the markers (dots) and not the lines

I tried df.plot(linestyle='None') but then I get an empty plot.

How can I change my code to show the dots/markers and hide the lines?

Upvotes: 0

Views: 315

Answers (1)

mozway
mozway

Reputation: 260975

pandas.DataFrame.plot passes **kwargs to matplotlib's .plot method. Thus you can use any of the matplotlib.lines.Line2D properties:

df.plot(ls='', marker='.')

markers without lines

Upvotes: 1

Related Questions