0

I want to compare just SanFrancisco, Seattle, and Portland. The code below displays every region. ax2.scatter(x=df['region']...

f, (ax1, ax2) = plt.subplots(1, 2, figsize=(14,8))
ax1.scatter(x=df['AveragePrice'], y=df['Total Volume'])
ax2.scatter(x=df['region'], y=df['AveragePrice'])
plt.tight_layout()
plt.xticks(rotation=90)
plt.show()
Matthias
  • 4,481
  • 12
  • 45
  • 84
  • Do you want to filter the rows? – mad_ Sep 12 '18 at 19:11
  • `ax2.scatter(x=df.loc[df['region'].isin(['SanFrancisco', 'Seattle', 'Portland']), 'region'), y=df['AveragePrice'])` – BallpointBen Sep 12 '18 at 19:12
  • I tried to simplify what I'm trying to do. So I changed the code to this and got an error message: "ValueError: x and y must be the same size." # Let's just compare San Francisco, Seattle, and Portland's prices. plt.scatter(x=df.loc[df['region'].isin(['SanFrancisco', 'Portland', 'Seattle'])], y=df['AveragePrice']) plt.xticks(rotation=90) plt.show() – Gabriel Henton Sep 13 '18 at 01:13

1 Answers1

0

You could try something like

ax1.scatter(x=df.loc[df['region'].isin(['SanFrancisco', 'Portland', 'Seattle']), 'region'), y=df['AveragePrice'])

You can find more examples here

genhernandez
  • 453
  • 1
  • 5
  • 19