## matplotlib-users

 [Matplotlib-users] Plotting boolean/logical data type From: Timo Heine - 2010-03-04 08:10:15 Attachments: Message as HTML ```Hello, I'v made a small program which plots data from a CAN-bus log file. Some of the data to plot is logical type on/off values (bit on or off). I have tried to find a way to plot this kind of data with no success. Basically what I want to do is to draw a horizontal line with relative y co-ordinates and absolute xmin and xmax co-ordinate. Then I could draw a line when a bit is high and have it always in plot area even when zooming etc. Like axhline(...) but with relative y and absolute x co-ordinates. Another way to do this could be using subplots, but I can't figure out how to use same x-scale on the both plots. Any suggestions? Best Regards Timo ```
 Re: [Matplotlib-users] Plotting boolean/logical data type From: Friedrich Romstedt - 2010-03-04 18:36:16 Attachments: Bits.png ```Do you want something like the attached? I created it with my package that no-one wants :-( >>> import diagram_cl >>> import diagram_cl.kernels.tk >>> import numpy >>> import Tkinter >>> d1 = diagram_cl.Diagram() >>> series = (numpy.random.random(100) > 0.5).astype(numpy.float) >>> for idx in xrange(0, len(series)): ... layer = diagram_cl.Layer2D(x = [0, series[idx]], y = [idx, idx], color = 'blue') ... d1.add_layer(layer) ... >>> tk = Tkinter.Tk() >>> k1 = diagram_cl.kernels.tk.Diagram(tk, d1) Double-right click on the figure, "Save", 200x200, "Bits.png". But of course, you can also do it with normal matplotlib (I'm not used to the pyplot things though, I'm rather using purist's API): Hmm, that's why it would be not the standard way to do it, so can anyone else post pure matplotlib means? Friedrich ```
 Re: [Matplotlib-users] Plotting boolean/logical data type From: Jae-Joon Lee - 2010-03-04 19:59:38 ```Not sure what exactly you want. Is this close? ax = subplot(111) tr = ax.get_xaxis_transform() ax.plot([0.2, 0.8], [0.5, 0.5], transform=tr) The x-coodinate is in data coordinate, but y coordinate is in (normalized) axes coordinate. More about the transforms behind matplotlib can be found in http://matplotlib.sourceforge.net/trunk-docs/users/transforms_tutorial.html -JJ On Thu, Mar 4, 2010 at 3:10 AM, Timo Heine wrote: > Hello, > I'v made a small program which plots data from a CAN-bus log file. Some of > the data to plot is logical type on/off values (bit on or off). I have tried > to find a way to plot this kind of data with no success. > Basically what I want to do is to draw a horizontal line with relative y > co-ordinates and absolute xmin and xmax co-ordinate. Then I could draw a > line when a bit is high and have it always in plot area even when zooming > etc. Like axhline(...) but with relative y and absolute x > co-ordinates. Another way to do this could be using subplots, but I can't > figure out how to use same x-scale on the both plots. > Any suggestions? > Best Regards > Timo > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ```
 Re: [Matplotlib-users] Plotting boolean/logical data type From: Friedrich Romstedt - 2010-03-18 22:01:18 ```2010/3/4 Timo Heine : > Basically what I want to do is to draw a horizontal line with relative y > co-ordinates and absolute xmin and xmax co-ordinate. Then I could draw a > line when a bit is high and have it always in plot area even when zooming > etc. Like axhline(...) but with relative y and absolute x > co-ordinates. I found a better solution candidate now, but I don't know whether it works: import matplotlib.transforms import matplotlib.lines trans = matplotlib.transforms.blended_transform_factory(axes.transData, axes.transAxes) line = matplotlib.lines.Line2D([xmin, xmax], [yrel, yrel], transform = trans, ) line.y_isdata = False axes.add_line(line) The code is taken from axes.py:Axes.axhline() with some alterations. Friedrich ```