Group Abstract Group Abstract

Message Boards Message Boards

1
|
15K Views
|
7 Replies
|
1 Total Like
View groups...
Share
Share this post:

How can i change the color of a graphics object?

Posted 11 years ago

I have a number of graphics objects, separately produced. I would like to combine them into one graphic, but color each one differently, so as to distinguish one from another. Something like

Show[
  Style[graph1,Red],
  Style[graph2,Green]
]

but this doesn't work for me. Is there anyway to do this?

Thank you Dave Golber

POSTED BY: David Golber
7 Replies
POSTED BY: Gianluca Gorni
Posted 11 years ago
POSTED BY: David Golber
Posted 11 years ago

Documentation on Show says "Options explicitly specified in Show override those included in the graphics expression" so I hoped that something like

Show[{p1,p2}, PlotStyle->{Red,Green}]

would work. But it doesn't. I think it would be very useful to be able to combine previously generated graphics in a single plot as you want. Particularly since we would be able to do the basic work without worrying about setting things up for later display. But I don't know how to do this -- maybe others will comment?

POSTED BY: David Keith
Posted 11 years ago

Thanks for trying to help, but this isn't my situation. Let me be more explicit:

gr1=ListPlot@elaborate calculation .... which takes several minutes and I don't want to run it again

gr2=ListPlot@ another elaborate calculation .... which takes several minutes and I don't want to run it again

When I made gr1 and gr2, I didn't plan on showing them together, so I didn't do anything special about the colors. Now I want to put them together, and have gr1 in one color and gr2 in another color. So I want to do something like

Show[ Style[gr1,Red], Style[gr2,Green] ]

but this doesn't work.

POSTED BY: David Golber
Posted 11 years ago

Thanks for trying to help, but this isn't my situation. Let me be more explicit:

gr1=ListPlot@elaborate calculation .... which take several minutes and I don't want to run it again

gr2=ListPlot@ another elaborate calculation .... which take several minutes and I don't want to run it again

When I made gr1 and gr2, I did't plan on showing them together, so I didn't do anything special about the colors. Now I want to put them together, and have gr1 in one color and gr2 in another color. Sop I want to do something like

POSTED BY: David Golber
Posted 11 years ago
Graphics[{{Red, Disk[{0, 0}, 1]}, {Green, Disk[{1, 1}, 1]}}]

enter image description here

POSTED BY: David Keith
Posted 11 years ago

I should also mention that the grouping I used above is not necessary. I often produce that in building the graphic list, but it is only the order that matters.

Graphics[{Blue, Disk[{-1, -1}, 1], Disk[{0, 0}, .5], Yellow, 
  Disk[{1, 1}, 1]}]

enter image description here

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard