0

when i am using s parameter for bubble whole plot is red When using "s" parameter

# Import numpy as np
import numpy as np

# Store pop as a numpy array: np_pop
np_pop = np.array(pop)

# Double np_pop
np_pop = np_pop*2

# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red', s = np_pop)

# Previous customizations
plt.xscale('log') 
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
plt.xticks([1000, 10000, 100000],['1k', '10k', '100k'])

# Display the plot
plt.show()

when s parameter is not used it shows constant bubble size but i want bubble size to be dependent on population when s parameter is not used it doesn't show red

# Import numpy as np
import numpy as np

# Store pop as a numpy array: np_pop
np_pop = np.array(pop)

# Double np_pop
np_pop = np_pop*2

# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red')

# Previous customizations
plt.xscale('log') 
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
plt.xticks([1000, 10000, 100000],['1k', '10k', '100k'])

# Display the plot
plt.show()
Akash Soni
  • 15
  • 3

1 Answers1

0

Try with a smaller np_pop:

np_pop = np_pop/5000 # or any other value that decrease the population(?)
Joe
  • 12,057
  • 5
  • 39
  • 55
  • @AkashSoni you are welcome, please consider to accept the answer by clicking on the tick on the left side of the answer :) https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Joe Aug 22 '18 at 13:02