Home > Mobile >  Trying to Combine Two Scatter Plots and Two Line Graphs with Matplotlib
Trying to Combine Two Scatter Plots and Two Line Graphs with Matplotlib

Time:12-03

I'm trying to create a graph that lists the high and low temperature per city on a specific day, but it seems like the y axes are just overlapping instead of plotting the point along it. Here is what I have:

fig, al = plt.subplots()
al.scatter(al_cities, al_min)
al.scatter(al_cities, al_max, c='red')
al.plot(al_cities, al_min, c='lightblue')
al.plot(al_cities, al_max, c='orange')
al.fill_between(al_cities, al_max, al_min, facecolor='gray', alpha=.3)
al.set_title('Highs and Lows in Alabama on January 10, 2016', fontsize=18)
al.set_xlabel('City', fontsize=14)
al.set_ylabel('Temperature', fontsize=14)

And this is what the graph looks like: Temperature plot

CodePudding user response:

I could not quite understand the problem, But I would like to suggest that you could use the normal plt.plot() rather than subplots if you just have one graph to show. (You could use errorbars to show max and min temperature)

  • Related