I am new to visualization in python. I am trying to plot the same dataset on the left but by using colors as gradient and gridlines to make it understandable. But I'm stuck and I don't know what I did, I just used the reference codes I got from other similar questions. Can someone help out?
import random
import matplotlib
import matplotlib.pyplot as plt
import tkinter as tk
from matplotlib.widgets import Slider
from matplotlib import colors
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib import style
import numpy as np
style.use('ggplot')
matplotlib.use('TkAgg')
def update(val):
pos = s_time.val
ax.axis([pos, pos+10, 20, 40])
fig.canvas.draw_idle()
def plot():
canvas = FigureCanvasTkAgg(fig,root)
canvas.get_tk_widget().pack(side=tk.TOP, fill = tk.BOTH, expand =1)
fig.subplots_adjust(bottom=0.25)
y_values = [random.randrange(41) for _ in range(40)]
x_values = [i for i in range(40)]
ax.axis([0, 9, 20, 40])
ax.plot(x_values, y_values)
#cmap = colors.ListedColormap(['red', 'blue','green'])
#bounds = [0,10,20,30]
#norm = colors.BoundaryNorm(bounds, cmap.N)
#ax1.imshow(ax, cmap=cmap, norm=norm)
im0 = ax1.pcolormesh([x_values,y_values], vmin=0, vmax=1, cmap="RdBu")
im = fig.colorbar(im0,cax=ax1)
ax1.grid(which='major', axis='both', linestyle='-', color='white', linewidth=0.5)
#ax1.set_yticks(np.arange(0, 40, 2.5))
ax_time = fig.add_axes([0.12, 0.1, 0.78, 0.03])
return ax_time
root = tk.Tk()
fig = plt.Figure(figsize = (10,10),dpi = 150)
ax=fig.add_subplot(121)
ax1=fig.add_subplot(122)
s_time = Slider(plot(), 'Time', 0, 30, valinit=0)
s_time.on_changed(update)
root.mainloop()