1

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 graph should I user from matplotlib library for this type of representation? how to plot each signal one over the other?

clock signal graph. I want something like this

1 Answer 1

3
  • To draw the lines themselves, use the plot method of an "axes" object. The plot method needs a range of y values for each signal. You'd have to generate those from your object, taking into account the required resolution. [Edit: the step 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 call plot 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.
Sign up to request clarification or add additional context in comments.

2 Comments

You might want to mention plt.step matplotlib.sourceforge.net/api/… in this particular case.
@user690682, don't forget to accept Eli's answer if this helped. Click the grey check-box just under the votes to accept his answer. If you don't accept answers, people may be more hesitant to assist in the future

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.