Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.1K Views
|
8 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to render level curves in several colors.

Posted 5 years ago
POSTED BY: David Barnes
8 Replies
Posted 5 years ago

Typo GBColor should be RGBColor. AspectRatio is specified twice, earlier one takes precedence.

ContourPlot[f[x, y], {x, 0, 1}, {y, 0, 2},
 ContourShading -> None,
 AspectRatio -> Automatic,
 Contours -> {0, .5, .7, .9},
 ContourStyle -> {RGBColor[0, 0, 0], RGBColor[1, 1, 0], RGBColor[0, 1, 0], RGBColor[0, 0, 1]}]

enter image description here

POSTED BY: Rohit Namjoshi
POSTED BY: David Barnes
POSTED BY: Markus van

I see that you have succeded in doing what I want to do. But when I try to use your code on my machine it does not work correctly. I am attaaching my code as a file if you want to look at it I would be most greatful. Dave Barnes.

Attachments:
POSTED BY: David Barnes

(* Here is some code that shows my problem witn=h cotour colors. The cut and paste function did not work right in my revious post *) a = 0; b = 1; c = 0; d = 2; f[x, y] := Sin[Pi x]^2 Sin[Pi y]^2; p1 = ContourPlot[f[x, y], {x, a, b}, {y, c, d}, ContourShading -> False, AspectRatio -> Automatic, Contours -> {.7}, PlotPoints -> 100, ContourStyle -> RGBColor[1, 0, 1], AspectRatio -> 1]; p2 = ContourPlot[f[x, y], {x, a, b}, {y, c, d}, ContourShading -> False, AspectRatio -> Automatic, Contours -> {.9}, PlotPoints -> 100, ContourStyle -> RGBColor[1, 0, 1], AspectRatio -> 1]; p3 = ContourPlot[f[x, y], { x, 0, 1}, {y, 0, 2}, ContourShading -> None, AspectRatio -> Automatic, Contours -> {0, .5, .7, .9}, PlotPoints -> 100, ContourStyle -> { RGBColor[0, 0, 0], RGBColor[1, 1, 0], RGBColor[0, 1, 0], GBColor[0, 0, 1]}, AspectRatio -> 1]

POSTED BY: David Barnes
Posted 5 years ago

Can I know the output? I mean I am interested in this, but I wanna see the output. :)

POSTED BY: Yasmin Hussain
Posted 5 years ago

Adding the command "ContourStyle -> {Red, Blue, Green, Yellow, Orange} " To my code results in a plot of the contour curves that are all orange colored. They are not {Red, Blue, Green, Yellow, Orange} in that order.

POSTED BY: Updating Name

Consider using the Option ContourStyle:

Clear[f];
f[x_, y_] := Sin[Pi x]^2 Sin[Pi y]^2;

ContourPlot[
    f[x, y], 
    {x, 0,1}, {y, 0,2}, 
    ContourShading -> None, 
     AspectRatio -> Automatic, Contours -> {0, .2, .5, .7, .9}, 
     PlotPoints -> 100, AspectRatio -> 1, 
     ContourStyle -> {Red, Blue, Green, Yellow, Orange}
]
POSTED BY: Markus van
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard