Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.5K Views
|
10 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Apply different colours to different ListPlots?

Posted 9 years ago

Hi,

I have not been able to figure out how to apply different colours to different ListPlots in a Show command. Specifically, how do I color one of the datasets in:

Show[ListPlot[data2], ListPlot[data], PlotRange -> All]

Specifying, e.g., PlotTheme -> “Web” at the end causes both plots to go red; putting PlotTheme -> “Web” after first ListPlot causes error message.

Any help will be greatly appreciated.

Strange

POSTED BY: Strange Ross
10 Replies

Hi Robert and Sander,

These are the datasets:

data = List[{{5.44, 1.}, {13.44, 1.31351}, {21.44, 1.74846}, {29.44, 1.83433}, {37.44, 2.06847}, {53.44, 2.36553}, {77.44, 2.53351}}]

and

data2 = List[{d * p, y110}, {(1 + d) * p, y210}],

where d = 0.68 and p = 8.

They plot nicely (in Black) from

Show[ListPlot[data2], ListPlot[data], PlotRange -> All]

Strange

POSTED BY: Strange Ross

Which version are you using? I can't remember the default color to be black! Should be blue-ish...

data = {{5.44, 1.}, {13.44, 1.31351}, {21.44, 1.74846}, {29.44, 1.83433}, {37.44, 2.06847}, {53.44, 2.36553}, {77.44, 2.53351}}
d = 0.68
p = 8
y110 = 2
y210 = 3
data2 = {{d*p, y110}, {(1 + d)*p, y210}}
ListPlot[{data, data2}, PlotStyle -> {Red, Black}]

notice that I omitted the extra List[...] command

POSTED BY: Sander Huisman

Hi again Sander,

I am sorry to say that your statement plots only data2 (albeit in red), but not data.

Perhaps this problem is harder to resolve than we think.

Strange

POSTED BY: Strange Ross

Then there is probably something 'different' (wrong?) with your data and data2:

data = Range[10]
data2 = 12 - Range[12]
ListPlot[{data, data2}, PlotStyle -> {Red, Blue}]

as you can see, this works perfectly fine. What are data and data2?

POSTED BY: Sander Huisman

What is data and data2? Both of Sander's suggestions should have worked fine.

POSTED BY: Robert Collyer
POSTED BY: Strange Ross

PlotStyle is a ListPlot option. As I said before:

ListPlot[{data2,data},PlotStyle->{Red,Black}]

Alternatively, if you really want to use Show for some reason:

Show[ListPlot[data2,PlotStyle->Red], ListPlot[data,PlotStyle->Black], PlotRange -> All]
POSTED BY: Sander Huisman

Depending what data and data2 are, you can simply do:

ListPlot[{data2,data}]
POSTED BY: Sander Huisman

Hi Sander,

I think you missed my point. I want to color one dataset red, while the other remains black.

And I still do not know how to accomplish this.

Strange

POSTED BY: Strange Ross

Try opening the documentation...

ListPlot[{data2,data},PlotStyle->{Red,Black}]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard