i have this chart but its not showing the data as i would like.
I need it to show all labels(hour) in the x plot from 1 to 24 instead its showing (0,5,10,15,25) and i would like it not to show the 0 and 25 of the x plot.
import tkinter
import matplotlib
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
import numpy as np
root = tkinter.Tk()
root.wm_title("Embedding in Tk")
xlst=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
ylst=[26, 25, 21, 43, 68, 107, 221, 569, 575, 599, 586, 432, 486, 525, 410, 328, 251, 166, 153, 105, 123, 93, 54, 69]
matplotlib.use("TkAgg")
figure = Figure(figsize=(8,6), dpi=80)
plot = figure.add_subplot(1, 1, 1)
plot.bar(xlst, ylst)
canvas = FigureCanvasTkAgg(figure, root)
canvas.get_tk_widget().grid(row=0, column=0)
tkinter.mainloop()
the 0 and 25 marked with the red arrow i whant it to start with 1 and end with 24 also with the green arrow i would like to show all hour´s
CodePudding user response:
You are missing just one line, so here you go:
plot.set_xticks(np.arange(1,25))