0

I have the following dataframe:

data = [
    ['unit1','A',3000,2.4],['unit1','A',4000,2.5],['unit1','A',5000,2.7],
    ['unit2','A',3000,2.1],['unit2','A',4000,2.3],['unit2','A',5000,2.6],
    ['unit3','A',3000,2.5],['unit3','A',4000,2.6],['unit3','A',5000,2.8]]
df = pd.DataFrame(data, columns=['unitname','channel','frequency','power'])

I would like to plot power over frequency, with each unit its own series and a legend corresponding to the unit name. With putting all of the series in the same plot.

1

2 Answers 2

3

Use seaborn to make your plots look nicer:

  • Using the sample dataframe provided in the question.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

plt.figure(figsize=(8, 8))
sns.lineplot(x='power', y='frequency', data=df, hue='unitname')
plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

IICU, this is what you need

df[df['unitname']=='unit1'].plot(x="power", y="frequency",title='unit1',colormap='Reds_r')
df[df['unitname']=='unit2'].plot(x="power", y="frequency",title='unit2', colormap='Blues_r')
df[df['unitname']=='unit3'].plot(x="power", y="frequency",title='unit3', colormap='Greens_r')

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.