Given a function f(x), how to ?
Generate the graph of the function and its derivative function on a figure with one bottom and top subplots that share the x-axis.
Both axes take their form with an input array with values from min to max
that are spaced by 0.5.
Each subplot must have a title
The top subplot must have the ylabel, whereas the bottom subplot must have both xlabel and ylabel
Each subplot shot have different styles of lines (colors, thickness, ...) and x ticks must also be in a different style(specifically the fontsize and rotation).
I did this :
#the function is f(x) while the derivative is df(x)
x = np.arange(min, max, 0.5) #scale
figure, (top, bottom) = plt.subplots(2, sharex=True, figsize = [5.0, 7.0])
top.plot(x, f(x), 'b', linewidth = 5)
top.set_title(Function f(x))
top.ylabel('f(x)')
figure.set_xticks(colors = 'r', fontsize = 12, rotation = 30)
bottom.plot(x, df(x), 'g-', linewidth = 8)
bottom.set_title('Derivative function of f(x)')
bottom.xlabel('x')
bottom.ylabel('df(x)')
plt.show(figure)
But it does not work. How could I fix everything ?
Edited for generalization