Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

question on Plot and Show plus Axis Labels:

107 views
Skip to first unread message

Gopinath Venkatesan

unread,
Jan 6, 2007, 11:29:30 PM1/6/07
to
Objective: to plot several graphs in a single plot as well as use labels for axis, and different colors or dashing and other styles for individual plots to distinguish. What I want to know is what are the graphic format commands that would work with the command "Show" (because I tried RotateLabel and its not working with Show). Or please read the below for more details.

I have y0, y, y1, and y2 as a list of values, and first I tried to plot all these list values using Plot (by default Plot function increments the x by fractions but in my case it is integer, like x={0,1,..10}; It didn't work. So I tried with ListPlot.

p0 = ListPlot[Thread[y0, x], PlotJoined -> True]
p = ListPlot[Thread[y, x], PlotJoined -> True]
p1 = ListPlot[Thread[y1, x], PlotJoined -> True]
p2 = ListPlot[Thread[y2, x], PlotJoined -> True]
Show[p0, p, p1, p2, AxesLabel -> {"x-value", "y-value"}, RotateLabel -> True]

And I used Show to plot all of them in a plot and tried to label the axis.

1. Problem is RotateLabel is not working with Show.
2. If I use a longer text label for axes (without RotateLabel option), the plot size gets smaller and text is as big as plots. Some scaling operation need to be done. no clue how to do this. Or should I change the font size of the text. I prefer not to change the text font size and keep the plot unscaled.

Please share your suggestions and any examples. Thanks

Gopinath Venkatesan
Graduate Student
University of Oklahoma

David Park

unread,
Jan 8, 2007, 4:58:36 AM1/8/07
to
Gopinath,

You don't give enough information. What do your y data lists look like? I
don't understand what the Thread statement is doing. RotateLabel only
applies to Frame plots and you are using an axis plot. Are you on a Mac or
PC? RotateLabel used to not work for Mac but I don't know what the situation
is now.

One of the severe weaknesses of Mathematica graphics is that the user only
has sure control of what goes on inside the 'frame' of the plot. Outside the
frame there is only weak and indirect control. By 'outside the frame' I mean
things like tick labels, frame labels and plot labels.

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

Bill Rowe

unread,
Jan 8, 2007, 5:00:41 AM1/8/07
to
On 1/6/07 at 11:43 PM, gopi...@ou.edu (Gopinath Venkatesan) wrote:

>Objective: to plot several graphs in a single plot as well as use
>labels for axis, and different colors or dashing and other styles
>for individual plots to distinguish. What I want to know is what are
>the graphic format commands that would work with the command "Show"
>(because I tried RotateLabel and its not working with Show). Or
>please read the below for more details.

>I have y0, y, y1, and y2 as a list of values, and first I tried to
>plot all these list values using Plot (by default Plot function
>increments the x by fractions but in my case it is integer, like
>x={0,1,..10}; It didn't work. So I tried with ListPlot.

>p0 = ListPlot[Thread[y0, x], PlotJoined -> True]
>p = ListPlot[Thread[y, x], PlotJoined -> True]
>p1 = ListPlot[Thread[y1, x], PlotJoined -> True]
>p2 = ListPlot[Thread[y2, x], PlotJoined -> True]
>Show[p0, p, p1, p2, AxesLabel -> {"x-value", "y-value"}, RotateLabel -> True]

Hmm... The usage of Thread above doesn't look right to me. I
assume you want to create a list of {x,y} pairs to supply to
ListPlot. If so, I would use Thread[{x,y}] instead of what
you've done above. And in the particular case where x takes on
the values {1,2,3...} it suffices to do simply ListPlot[y]
rather than ListPlot[Thread[{x,y}]]

>And I used Show to plot all of them in a plot and tried to label the
>axis.

>1. Problem is RotateLabel is not working with Show.

>2. If I use a longer text label for axes (without RotateLabel option),
>the plot size gets smaller and text is as big as plots. Some scaling
>operation need to be done. no clue how to do this. Or should I change
>the font size of the text. I prefer not to change the text font size
>and keep the plot unscaled.

I would use the following approach

First, generating some data

y = Table[Random[], {10}];
y1 = Sort@Table[Random[], {10}];
y2 = Reverse@Sort@Table[Random[], {10}];

then to plot the data

Show[
Block[{$DisplayFunction = Identity},
ListPlot[#, PlotJoined -> True] & /@ {y, y1, y2}],
FrameLabel -> {"x-value", "y-value"}, Axes -> None, Frame
-> {True, True,
False, False}];

Here, I've used FrameLabels in place of AxesLabels and replaced
the axes with a frame constructed to look like a set of axes.
--
To reply via email subtract one hundred and four

Pratik Desai

unread,
Jan 9, 2007, 7:11:37 AM1/9/07
to

Hello Gopinath,

Why not use MultipleListPlot? This is available through the Standard
packages
In your help browser
Go to Add-ons and Links->Graphics->MultipleListPlot


Hope this helps

Pratik Desai
Wolfram Research

Gopinath Venkatesan

unread,
Jan 9, 2007, 7:13:59 AM1/9/07
to
Hello David

Thanks for showing interest in my problem and for posting reply. Please see the below sample code. This sample is not related to my study, this is just to illustrate.

\!\(\(x = Table[i, {i, 1, 15, 1}];\)\[IndentingNewLine]
\(v = Table[Sin[\(π\/15\) x[\([i]\)]], {i, 1, 15, 1}];\)\[IndentingNewLine]
\(y[j_] := Cos[π\/15\ x[\([j]\)]];\)\[IndentingNewLine]
\(y1 = Table[y[j], {j, 1, 15, 1}];\)\[IndentingNewLine]
\(y2 = Table[v[\([j]\)], {j, 1, 15, 1}];\)\[IndentingNewLine]
p1 = ListPlot[Thread[y1, x], PlotJoined -> True]\[IndentingNewLine]
p2 = ListPlot[Thread[y2, x], PlotJoined -> True]\[IndentingNewLine]
Show[p1, p2]\)

I could not use Plot for plotting a list of values of y1 and y2 for the x values. I tried using the below Plot command and got error,

p1=Plot[y1,{x,1,15}]

that y1 is not a machine readable value at x = 1.0000000+
meaning that Plot tries to do a smooth fit between these intervals. In my case, x value increments by integer value, say unit increase. For that discrete sets of x values, I have respective y values and for using ListPlot, I have to thread these x and y values. Thats why I am using Thread.

If you can tell me how to use Plot function for plotting the values above, that will be great.

Or please suggest otherways where I have to use the combinations of ListPlot, Show, and others to produce a multi-plot with a axes label rotated (y axis), use Plot Legends to work with Show (or an alternate to Plot Legend since it doesnt work with Show), and coloring them differently. I figured out how to color them differently - using RBCColor option. But still got stuck with the Legends and the rotate labels options.

RotateLabel works fine with Frames. If I use Frames, will that solve other problems too. I am trying, but just in case, if you know the answer, please hint me. Thanks,

Bob Hanlon

unread,
Jan 10, 2007, 2:48:39 AM1/10/07
to
x=Range[15];

y1=Table[Cos[x*Pi/15],{x,15}];

y2=Table[Sin[x*Pi/15],{x,15}];

Plot[{Cos[t*Pi/15],Sin[t*Pi/15]},{t,0,15},
Epilog->{AbsolutePointSize[4],
Red,Point/@Thread[{x,y1}],
Blue,Point/@Thread[{x,y2}]}];

Needs["Graphics`"];

MultipleListPlot[y1,y2,
PlotJoined->True,SymbolStyle->{Red,Blue}];

DisplayTogether[
ListPlot[y1,PlotJoined->True,
PlotStyle->{Red}],
ListPlot[y2,PlotJoined->True,
PlotStyle->{Blue}]];


Bob Hanlon

---- Gopinath Venkatesan <gopi...@ou.edu> wrote:
> Hello David
>
> Thanks for showing interest in my problem and for posting reply. Please see the below sample code. This sample is not related to my study, this is just to illustrate.
>
> \!\(\(x = Table[i, {i, 1, 15, 1}];\)\[IndentingNewLine]

> \(v = Table[Sin[\(Ï€\/15\) x[\([i]\)]], {i, 1, 15, 1}];\)\[IndentingNewLine]
> \(y[j_] := Cos[Ï€\/15\ x[\([j]\)]];\)\[IndentingNewLine]

0 new messages