python matplotlib clock signal type graph help:
I am looking to plot a graph that depicts a clock signal. The following is what I am looking forward to plot.
I have say four objects. Object one is either in state 1 or state 0 for a particular length of time. I also have to mention (some where on the top of the clock signal) how long is the zero period and how long is the 1 period.
I have to do the above procedure for rest of the three objects one over the other so that I can compare those clock signal type graphs. I have attached an image I want something on the lines of this image. Where out2 out1 etc are my objects and I mention the length of each 0 or 1 state above each graph. I do not want those clock and reset signals.
Can some one tell me what type of gr开发者_JAVA技巧aph should I user from matplotlib library for this type of representation? how to plot each signal one over the other?
- To draw the lines themselves, use the
plot
method of an "axes" object. Theplot
method needs a range ofy
values for each signal. You'd have to generate those from your object, taking into account the required resolution. [Edit: thestep
method seems to be even easier to use for clock-like singals. Thanks to Joe for pointing this out in a comment]. - To draw them all together in the way you want, the best thing would be to use subplots (
add_subplot
method of a figure). You could alternatively just callplot
several times on the same axes, but for that you'd have to compute the data points before-head to place the different signals separately vertically.
精彩评论