On Wed, Jul 7, 2010 at 11:45 AM, Raul Miller <[email protected]> wrote: > On Wed, Jul 7, 2010 at 11:01 AM, Thomas Costigliola <[email protected]> > wrote: >> I needed to draw some bar plots with lines over them and noticed that >> if you don't take special care the points of the line do not >> correspond to the centers of the bars. This can be seen in this >> example: >> >> load 'plot' >> DATA=. 1 2 3 2.5 4 0.5 1 >> pd 'reset' >> pd 'type bar;barwidth 1' >> pd DATA >> pd 'type line marker;color black;' >> pd (1.5"0)DATA >> pd 'show' > > Tthe second plot has little to do with the centers of the bars. > > Consider, for example: > pd (1.5"0)0,DATA >
I should have mentioned that the line series corresponds to the bar series in some way. So a more realistic example is to compare the following. The line is the cumulative of the bars: DATA=. 1 2 3 2.5 _4 0.5 1 pd 'reset' pd 'type bar;barwidth 1;xlabel jan feb mar apr may jun jul' pd DATA pd 'type line marker;color black;pensize 3' pd +/\ DATA pd 'show' DATA=. 1 2 3 2.5 _4 0.5 1 pd 'reset' pd 'type bar;barwidth 1;xlabel jan feb mar apr may jun jul' pd DATA pd 'type line marker;color black;pensize 3' pd (((0.5 * [:i: _1: j. <:@#) + i...@#) ; +/\) DATA pd 'show' The first doesn't look right where as the second looks ok. You're examples show though, that another way to go about it is to add artificial data points instead of specifying x values. I will experiment with that. > If you also want dots in the center, you could try: > pd (1.5"0)0,2#DATA > > If there was a way of turning off every other > dot, that might get you want you wanted. > > But, basically, your first plot ignores "x" values > and your second plot ignores "y" values, and > the plot mechanism itself has a lot of undocumented > aspects, so I usually avoid it when I want precise control. > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
