Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15157 > unrolled thread
| Started by | Nigel King <nigel.king@cambiumnetworks.com> |
|---|---|
| First post | 2013-07-10 07:23 +0000 |
| Last post | 2013-07-10 07:23 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Multiple Line coloring and Dashing in ListPlot Nigel King <nigel.king@cambiumnetworks.com> - 2013-07-10 07:23 +0000
| From | Nigel King <nigel.king@cambiumnetworks.com> |
|---|---|
| Date | 2013-07-10 07:23 +0000 |
| Subject | Re: Multiple Line coloring and Dashing in ListPlot |
| Message-ID | <krj24u$1jn$1@smc.vnet.net> |
All,
I wanted to extend the ideas from Bob and Alexei, because I have had trouble with doing this nicely.
$Version 9.0 for Mac OS X x86 (64-bit) (January 24, 2013)
(* When you want a set of legends one needs to extend the idea a little further *)
(* for a simple table of legends *)
legendTable[pairs_]:=TableForm[pairs,TableSpacing->{1,0.5}]
(* There seems to be no default for dashing so I define noDots *)
noDots=Dashing[{1,0}];
(* Create a general set of PlotStyles for some plots *)
colors={Red,Blue,Green,Brown,Pink,Cyan,Magenta,Gray,Orange};
dashings={noDots,DotDashed,Dotted,Dashed};
plotStyles=Flatten[Table[Directive[i,Thick,j],{j,dashings},{i,colors}]];
(* From an example by Bob Hanlon *)
plotList=Table[{i,RandomReal[{2 i,2 i+1},{20}]},{i,36}];
plots=plotList[[All,2]];
legends=plotList[[All,1]];
ListPlot[plots,
PlotStyle->plotStyles,
Joined->True,
PlotMarkers->Automatic,
ImageSize->600,
AspectRatio->1,
PlotLegends->Placed[LineLegend[plotStyles,legends,
LegendLabel->Style["Plots",16],
LegendFunction->"Frame",LegendMargins->5,LabelStyle->11,
LegendLayout->legendTable],After]]
For the function plots this example may give some useful ideas
(* an interesting example showing a number of techniques which I have learnt *)
(* Create a plot list in an easy to recognise form *)
plotList={
{Sin[x],"sin(x)",{Blue,noDots}},
{Cos[x],"cos(x)",{Red,noDots}},
{Tan[x],"tan(x)",{Green,noDots}},
{Cot[x],"cot(x)",{Brown,Dotted}},
{Sec[x],"sec(x)",{Pink,Dotted}},
{Csc[x],"csc(x)",{Cyan,Dotted}},
{Sinh[x],"sinh(x)",{Blue,DotDashed}},
{Cosh[x],"cosh(x)",{Red,DotDashed}},
{Tanh[x],"tanh(x)",{Green,DotDashed}},
{Coth[x],"coth(x)",{Brown,Dashed}},
{Sech[x],"sech(x)",{Pink,Dashed}},
{Csch[x],"csch(x)",{Cyan,Dashed}}
};
(* extract the plots *)
plots=plotList[[All,1]];
(* extract the legends *)
legends=plotList[[All,2]];
(* extract the plotStyles and control the thickness (in this case Medium is the default)*)
plotStyles=Map[Directive[Thickness[Medium],#[[1]],#[[2]]]&,
plotList[[All,3]]];
(* Modify legendTable to give two columns of functions *)
legendTable[pairs_]:=TableForm[Partition[pairs,6],
TableSpacing->{2,2,0.5},
TableDirections->{Row,Column,Row},
TableAlignments->{Left,Center}]
Plot[plots,{x,0,2Pi},PlotStyle->plotStyles,Frame->True,
PlotLegends->Placed[LineLegend[plotStyles,legends,
LegendLabel->Style["Plots",16],
LegendFunction->"Frame",LegendMargins->5,LabelStyle->11,
LegendLayout->legendTable],After],
ImageSize->500]
I hope this helps
Nigel King
On 3 Jul 2013, at 10:01, graser <graser@gmail.com> wrote:
Dear Mathematica Users,
I have a question about the coloring and dashing lines in listplot.
For example, Let's say there is a multiple data set like
data = Table[RandomReal[{2 i, 2 i + 1}, {20}], {i, 9}];
I want to plot them in listplot or listloglogplot with all different color and all different dashing with (joined -> True).
How can I do it automatically or minimum option?
The default number of coloring in mathematica (I am in still 8) is 4. after that, it repeat same color.
please help me!
Thanks!
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web