Re: ListPlot & lots 'o dots.
- To: mathgroup at smc.vnet.net
- Subject: [mg87797] Re: ListPlot & lots 'o dots.
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Wed, 16 Apr 2008 22:35:51 -0400 (EDT)
- References: <fu4flb$nj7$1@smc.vnet.net>
Annetts729 wrote: > Hi, > > Apparently ListPlot has a quirk on my systems (XP SP2/3, 6.0.2) > > With test data > > test = Table[N@Sin[n \[Pi] x], {n, 1, 5, 1}, {x, -\[Pi], \[Pi], \ > [Pi]/50}]; > > ListPlot[test] produces a plot with lots 'o dots as expected. It's > easy to see which dots correspond to which frequency by connecting > points in each data set > > ListPlot[test, Joined->True] > > We can correct the ordinate scale using > > ListPlot[test, Joined->True, DataRange->{-\[Pi], \[Pi]}], and for > lots 'o plots this looks messy. > > Using SetOptions, we can set ListPlot up so that we don't need to > specify Joined & a data range every time we use ListPlot using > > SetOptions[ListPlot, DataRange -> {-\[Pi], \[Pi]}, Joined -> > True ]; > > We can confirm ListPlot's new settings either by removing the ";" or > using Options@ListPlot. > > For me this is where the problem starts. > > After an appropriate SetOptions (like above), ListPlot[test] should > give me a plots that is joined & has the correct ordinate scale. For > me it doesn't, despite Joined->True and DataRange, ListPlot[test] gets > ma a plot with lots 'o dots and the wrong scale. I know there's a > point to SetOptions since I can set (eg) a PlotRange and FrameLabels. > It's just that ListPlot (apparently) ignores DataRange & Joined so > that I have to specify them each time I use ListPlot. > > I'd like to know if this problem restricted to my system. In the > event that it can be reproduced, I'll report it as a bug. > > Tests. > test = Table[N@Sin[n \[Pi] x], {n, 1, 5, 1}, {x, -\[Pi], \[Pi], \[Pi]/ > 50}]; (* generate test data *) > ListPlot[test] (* plot w/ lots o dots *) > ListPlot[test, Joined -> True, DataRange -> {-\[Pi], \[Pi]}] (* > desired plot *) > SetOptions[ListPlot, DataRange -> {-\[Pi], \[Pi]}, Joined -> True, > FrameLabel -> {"Hi", "Lo"}, PlotRange -> {0, [Pi]/2}]; (* set default > options for ListPlot *) > ListPlot[test] (* dotty plot, incorrect ordinate but correct abscissa > & labels -- WTF? *) > > > Regards, > > Dave. > > > > > > It would seem that ListPlot is not responding to changed options! Although this is a bug, I would not recommend setting the options of built-in functions because it can cause confusion over time. A better approach is to define your own plotting function which calls ListPlot with the required options. David Bailey http://www.dbaileyconsultancy.co.uk