I have gridded temperature data for a particular point pulled into an list, and am plotting this on a bar chart, as follows:
Inevitably, temperatures from this gridded dataset will fall below 0 degrees, and I am looking to scale the Y-axis such that a mix of bars with both positive and negative values will both ascend towards the top of the image.
I have looked into the example code found here, however to the best of my understanding, this code assumes that all values in the array are negative, which the dataset I am working with will not have.
The code assembled to generate the graph seen below (excluding construction of the initial list) is as follows:
objects = (''+ mon0 +' '+ date0 +'', ''+ mon1 +' '+ date1 +'', ''+ mon2 +' '+ date2 +'', ''+ mon3 +' '+ date3 +'', ''+ mon4 +' '+ date4 +'', ''+ mon5 +' '+ date5 +'', ''+ mon6 +' '+ date6 +'', ''+ mon7 +' '+ date7 +'', ''+ mon8 +' '+ date8 +'', ''+ mon9 +' '+ date9 +'', ''+ mon10 +' '+ date10 +'')
y_pos = np.arange(len(objects))
fig, ax = plt.subplots(figsize=(14,8))
bar_width = 0.40
rects = plt.bar(y_pos, btv_list, bar_width, color='#cc0000', edgecolor='black')
plt.xticks(y_pos, objects)
plt.ylabel('Temperature (°F)')
plt.xticks(y_pos, objects)
for rect in rects:
y_value = rect.get_height()
x_value = rect.get_x() + rect.get_width() / 2
space = 3
va = 'bottom'
label = y_value
plttxt = plt.annotate(label, (x_value, y_value), xytext=(0, space), textcoords="offset points", ha='center', va=va)
plttxt.set_fontsize(14)
plttxt.set_weight('semibold')
fig.tight_layout()