Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- figure = plt.figure()
- axes = figure.add_subplot (1, 1, 1)
- axes.plot(m_time, m_temp, linestyle='-', color='orange', label = 'max : '+str(max(m_temp))+'\n'+'min : '+str(min(m_temp)), linewidth=2)
- y_step = matplotlib.ticker.MultipleLocator(base=0.5)
- axes.yaxis.set_major_locator(y_step)
- plt.xticks(rotation=90)
- f_hour_min = mpl.dates.DateFormatter('%H:%M')
- f_day = mpl.dates.DateFormatter('%a %d. %b %Y')
- #format grid
- axes.xaxis.grid(True, which='major', linestyle='solid')
- axes.xaxis.grid(True, which='minor')
- axes.yaxis.grid(True, which='major')
- axes.axis([min(m_time), max(m_time), min(m_temp)-0.5, max(m_temp)+0.5])
- #format major labels out
- axes.xaxis.set_major_formatter(f_day)
- day_tick = mpl.dates.DayLocator()
- axes.xaxis.set_major_locator(day_tick)
- major_labels = [tick.label1 for tick in axes.xaxis.get_major_ticks()]
- for label in major_labels:
- label.set_rotation(90)
- label.set_ha('center')
- label.set_va('bottom')
- label.set_bbox(dict(facecolor='white', edgecolor='black', boxstyle='round,pad=0.5'))
- axes.xaxis.set_tick_params(which='major', pad=-10)
- #format minor labels out
- axes.xaxis.set_minor_formatter(f_hour_min)
- min_tick = mpl.dates.MinuteLocator(interval=30)
- axes.xaxis.set_minor_locator(min_tick)
- minor_labels = [tick.label1 for tick in axes.xaxis.get_minor_ticks()]
- for label in minor_labels:
- label.set_rotation(50)
- label.set_ha('right')
Advertisement
Add Comment
Please, Sign In to add comment