7
$\begingroup$

Say, I have a colorlist

listColor={Black,Brown,Red,Cyan}

Now, I have some Plot function that I can use this list:

Plot[{Sin[x],Cos[x],x,x^2},{x,1,100},PlotStyle->listColor]

Everything went fine. Now, I wanted to make the plot style "thick"

But when I add:

Plot[{Sin[x],Cos[x],x,x^2},{x,1,100},PlotStyle->{Thick,listColor}]

The listColor breaks down. I understand I actually need

listColor={{Thick, Black},{Thick, Brown},{Thick, Red},{Thick, Cyan}}

But adding {Thick} to each entry of listColor is too hard. Is there anyway that I can append {Thick, } to each entry of the list elegantly?

I notice that using

Transpose[{Table[Thick,{i,1,4}],listColor}]

might work but it looks unnecessary...

$\endgroup$

1 Answer 1

6
$\begingroup$

You can use BaseStyle for some of directives:

listColor = {Black, Brown, Red, Cyan}
Plot[{Sin[x], Cos[x], x, x^2}, {x, 0, 1}, PlotStyle -> listColor, BaseStyle -> Thick]

enter image description here

Another way is to use all in PlotStyle:

PlotStyle -> Thread[Directive[listColor, Thick]] (*or just*)
PlotStyle -> Thread[{listColor, Thick}] (* or using your approach:*)
PlotStyle -> Table[{Thick, i}, {i, listColor}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.