Reputation: 1592
I have a big dataset that I would like to plot as a line plot in seaborn.
My dataset is consisted of different measurments of specific plant that were taken in different data, so basically I would like to plot each row in my dataset as one line in the line plot as I have tried to demonstrate in this image:
For that goal I have tried to use seaborn with the next code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
####THERE WAS MORE PROCESSING OF THE DATA THAT I BELIEVE IS IRRELEVANT
####Here I have tried to determine what I want in my axis. I haven't really use the value wavelength
#X axis
wavelength=new_db.columns.values[5:]
#y axis- values
#basically the outcome of this suppose to be a table with only values when ach row represents a hour
colum=new_db.columns.tolist()
new_db=new_db[cols[1:]]
#here i'm trying to create the plot
sns.set(style="whitegrid")
sns.lineplot(data=new_db, palette="tab10", linewidth=2.5)
#ERROR
ValueError: These
style
levels are missing dashes: set(['747.5', '814.81', '842.44', '906.34', '433.71', '667.2', '431.09', '512.97', '850.75', '882.67', '751.61', '911.92', '601.11', '847.98', '917.5', '828.61', '679.4', '440.29', '705.21', '729.74', '421.9', '959.5', '648.26', '956.69', '446.87', '445.55', '727.01', '605.14', '506.33', '856.29', '531.58', '889.63', '576.97', '924.49', '503.68', '897.98', '707.93', '970.73', '953.89', '839.67', '510.31', '678.04', '772.17', '473.24', '659.08', '813.43', '442.92', '781.78', '688.9', '623.98', '684.82', '634.76', '834.14', '955.29', '575.63', '589.03', '817.57', '474.56', '638.81', '935.68', '454.77', '571.62', '871.55', '587.69', '987.61'...............
(The original message was much longer with more numbers.)
I have tried also to create it with this:
sns.set(style="whitegrid")
ax = sns.lineplot(x="wavelength", y="new_db")
but got this error:
ValueError: Could not interpret input 'wavelength'
I don't know how to solve it.
This is the prosuct I would like to get in the end:
Upvotes: 2
Views: 14528
Reputation: 771
Just put dashes=False and it should solve your issue and then you can build on that using the various parameters.
sns.lineplot(data=df, dashes = False)
Upvotes: 1
Reputation: 76
I think the default len for dash styles list is 6. If you want more styles, you have to define them manually and add them through:
dash_styles = ["",
(4, 1.5),
(1, 1),
(3, 1, 1.5, 1),
(5, 1, 1, 1),
(5, 1, 2, 1, 2, 1),
(2, 2, 3, 1.5),
(1, 2.5, 3, 1.2),
# etc
]
sns.lineplot(..., dashes=dash_styles,...)
Upvotes: 2
Reputation: 4827
How about transposing you DataFrame?
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame(np.random.rand(3, 10)).T
print(df)
DataFrame:
0 1 2
0 0.341005 0.925077 0.541746
1 0.324769 0.558320 0.902804
2 0.647871 0.630663 0.607212
3 0.722298 0.745091 0.630445
4 0.209836 0.386576 0.076790
5 0.347911 0.237178 0.446102
6 0.174991 0.777129 0.109934
7 0.022564 0.388223 0.464438
8 0.359771 0.722761 0.837942
9 0.091696 0.474859 0.840078
Plot
sns.lineplot(data=df.iloc[:, :2])
Result:
Upvotes: 4