Re: Problem with DateListPlot Aspect Ratio
- To: mathgroup at smc.vnet.net
- Subject: [mg117613] Re: Problem with DateListPlot Aspect Ratio
- From: Armand Tamzarian <mike.honeychurch at gmail.com>
- Date: Thu, 24 Mar 2011 06:30:50 -0500 (EST)
- References: <imc941$1k1$1@smc.vnet.net>
On Mar 23, 6:56 pm, "Miranda, Juan" <juan.mira... at hp.com> wrote: > Hi everyone, > > I have had some troubles with DateListPlot, my version of Mathematica is 8.0.1, so this is my problem. > > I'm creating a random time indexed list with 300 data, in order to plot the data I'm using the DateListPlot function, I want to have the PlotRange varying with an slider in order to see a larger or smaller range of data. So I wrote the next problem to exemplify what is happening, I have an Slider that changes the percentage of time I want to see from 0 to 1, there are two DateListPlots, both of them plot the same 300 data points, and have the ImageSize defined as {800,200}, the first one as the AspectRatio defined as GoldenRatio, the second one has the AspectRatio defined as Full because I want the graphic to cover the whole imagesize space. So when percentage has the value of 1 (To show 100% the time range), both graphics work as expected. But if I move the Slider in order to select a value of percentage behind 0.7 (approx. 70%), the first graph that is not the one that I want to implement works just fine, but the second one that is the one I want to implement just show s o! me weird lines. I'm starting thinking that it is a bug. Can someone tell me how to correct this bug? I want to conserve the Time related ticks in the DateListPlot. > > Needs["Calendar`"] > pointsnum = 300; > percentage = 1; > data = Transpose[{Map[(DatePlus[{2011, 1, 1}, #]) &, > Range[pointsnum]], RandomReal[100, pointsnum]}]; > Grid[{{Grid[{{Slider[Dynamic[percentage]], Dynamic[percentage]}}]}, { > Dynamic[ > DateListPlot[data, Joined -> True, ImageSize -> {800, 200}, > AspectRatio -> GoldenRatio, > PlotRange -> {{data[[1, 1]], > DatePlus[data[[1, 1]], (pointsnum - 1)*percentage]}, {0, > 100}}]] > }, { > Dynamic[ > DateListPlot[data, Joined -> True, ImageSize -> {800, 200}, > AspectRatio -> Full, > PlotRange -> {{data[[1, 1]], > DatePlus[data[[1, 1]], (pointsnum - 1)*percentage]}, {0, > 100}}]] > }}] > > Best. > > Juan Not sure why this is happening but it seems that if you give AspectRatio an explicit number the problem goes away: Column[{ Row[{Slider[Dynamic[percentage], ImageSize -> Medium], Spacer[{4, 0}], Dynamic@NumberForm[percentage, {4, 3}]}], Dynamic[ DateListPlot[data, Joined -> True, ImageSize -> {800, 200}, ImagePadding -> {{30, 10}, {30, 10}}, AspectRatio -> GoldenRatio, PlotRange -> {{data[[1, 1]], DatePlus[data[[1, 1]], (pointsnum - 1) percentage]}, {0, 100}}], TrackedSymbols :> {percentage}], Dynamic[ DateListPlot[data, Joined -> True, ImageSize -> {800, 200}, ImagePadding -> {{30, 10}, {30, 10}}, AspectRatio -> 1/4, PlotRange -> {{data[[1, 1]], DatePlus[data[[1, 1]], (pointsnum - 1) percentage]}, All}], TrackedSymbols :> {percentage}] }, Alignment -> Center] Mike