1
import pandas as pd 
import matplotlib.pyplot as plt

def csv_til_liste(filnavn):
    occuDF = pd.read_csv(filnavn)
    occuList=occuDF.values.tolist()
    return occuDF, occuList


occuDF, occuList = csv_til_liste("occupancy.csv")
plt.figure(1)
occuDF.boxplot(column = 'Temperature', by = 'Occupancy')
plt.suptitle('')

x=(1, 2, 3, 4, 5)
y=(1,2,3,4,5)
plt.figure(2)
plt.plot(x,y)
plt.show()

When I run the program, the two plots are plotted in one figure, but I want them in two separate figures.

1 Answer 1

1

The pandas.DataFrame.boxplot takes an ax parameter, as written in the docs.

So you can use:

fig1 = plt.figure()
ax1 = fig1.add_subplot(1, 1, 1)
occuDF.boxplot(column = 'Temperature', by = 'Occupancy', ax=ax1)
plt.suptitle('')

x=(1, 2, 3, 4, 5)
y=(1,2,3,4,5)

fig2 = plt.figure(2)
ax2 = fig2.add_subplot(1, 1, 1)
ax2.plot(x,y)

plt.show()

Otherwise, you can plot in different subplots of the same figure by applying minimal changes.

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

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.