Re: Problem with DateListPlot Aspect Ratio
- To: mathgroup at smc.vnet.net
- Subject: [mg117612] Re: Problem with DateListPlot Aspect Ratio
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 24 Mar 2011 06:30:39 -0500 (EST)
Needs["Calendar`"]
pointsnum = 300;
percentage = 1;
data = Transpose[{
DatePlus[{2011, 1, 1}, #] & /@ Range[pointsnum],
RandomReal[100, pointsnum]}];
Column[{
Row[{
"Portion of data", Spacer[5],
Slider[Dynamic[percentage], ImageSize -> Large], Spacer[5],
Dynamic[percentage]}],
Dynamic[
DateListPlot[
data,
Joined -> True,
ImageSize -> 800,
AspectRatio -> 1/4,
PlotRange ->
{
{data[[1, 1]],
DatePlus[data[[1, 1]], (pointsnum - 1)*percentage]},
{-2, 102}}]]}]
Bob Hanlon
---- "Miranda 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 som
e!
!
!
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