cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Overlaying a contour plot with an x-y plot

bobg100x
9-Granite

Overlaying a contour plot with an x-y plot

This is a follow-up question to a recent Mathcad 15 solution provided by Werner_E. I manipulated some control parameters and "converted" your "rainbow-effect" surface plot of a two-variable function into a nice-looking "contour" plot [see attached file]. How can I overlay it with an x-y plot of a parabola [shown in the second attached file] so that the vertex of this curve coincides with the contour plot [x, y] = [0, 0] and opens to the right [i.e., in the y direction]? 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:bobg100x)

Its funny but now we are back to where you started from - Prime 😉

Unfortunately Mathcad 15 does not offer a way out of the box to add a legend to a contour plot. This is one of the few improvements in Prime. On the other hand, in Prime you have not much control over the colors used (in Mathcad you can provide your own color map) but can just chose among a handful. Also I don't think that you can add your parabola in the Prime plot.

Anyway, for whatever it may be worth - here is what Prime can do for you. You may also notice that on contrary to a surface plot you are able to stretch the contour plot (isolines plot) the way you demanded. I added the arrows to show which values you can change directly in the plot to have more control over the number of isolines, etc. basically the first, second and last value in every scale.

I used the Prime file you posted in your initial thread. I would prefer the approach with "CreateMesh" but in this file I didn't change your approach with the range variables and of course they work OK, too.

Werner_E_0-1580743585522.png

 

Of course its possible to add a legend in Mathcad, too, but you have to create it yourself. Basically you add a second contour plot of a simple plane and have to take care to use the same color map and the same max and min z-values in both plots.

The need for a legend in contour plots resulted in a lot of questions for them in this forum quite a while ago. I attach one of my answer files (could't find the thread it stems from) with a possible solution.

 

 

View solution in original post

7 REPLIES 7
LucMeekes
23-Emerald III
(To:bobg100x)

Can you not just shove one partly behind the other?

Success!
Luc
Werner_E
25-Diamond I
(To:bobg100x)

One possible way is to turn the parabola into a 3D parametric curve, use "CreateSpace" and add it as an additional plot, which you have to format as "Data points"/"Scatter Plot". You can decide to omit the dots and just draw line segments. The distance between the dots can be controlled by the last argument of "CreateSpace".

Werner_E_0-1580655766762.png

 

It was necessary to give the curve some "height" (here 0.5) to avoid the curve being covered up partially by the surface plot. Another way to cope with this could be to add some degree of transparency to the surface plot.

 

 

Werner_E
25-Diamond I
(To:Werner_E)

The MC15 sheet is now attached.

I also played around with transparency and added a true contour plot as a ground base.

Werner_E_0-1580655429599.png

 

If you would like to use the built in contour plot only, you have to change the arguments of the function to achieve the same plot as yours because we have not other way to change the axis orientation in the contour plot.

Werner_E_2-1580655680185.png

 

 

Fantastic! Stripped-down contour plots with and without the parabola overlay will work out perfectly [see attached Word file].

One more question: Is it possible to generate a multi-colored "bar" similar to that used by weather forecasters to illustrate temperature variation on a map [example shown in the second attached file] to match the variation of z(x,y) between its calculated values of 0 to 1.0?

 

Werner_E
25-Diamond I
(To:bobg100x)

Its funny but now we are back to where you started from - Prime 😉

Unfortunately Mathcad 15 does not offer a way out of the box to add a legend to a contour plot. This is one of the few improvements in Prime. On the other hand, in Prime you have not much control over the colors used (in Mathcad you can provide your own color map) but can just chose among a handful. Also I don't think that you can add your parabola in the Prime plot.

Anyway, for whatever it may be worth - here is what Prime can do for you. You may also notice that on contrary to a surface plot you are able to stretch the contour plot (isolines plot) the way you demanded. I added the arrows to show which values you can change directly in the plot to have more control over the number of isolines, etc. basically the first, second and last value in every scale.

I used the Prime file you posted in your initial thread. I would prefer the approach with "CreateMesh" but in this file I didn't change your approach with the range variables and of course they work OK, too.

Werner_E_0-1580743585522.png

 

Of course its possible to add a legend in Mathcad, too, but you have to create it yourself. Basically you add a second contour plot of a simple plane and have to take care to use the same color map and the same max and min z-values in both plots.

The need for a legend in contour plots resulted in a lot of questions for them in this forum quite a while ago. I attach one of my answer files (could't find the thread it stems from) with a possible solution.

 

 

I wound up taking screen shots of your contour/surface plots and color bar, added a number range between 0 and 1, adjusted the aspect ratios and sizes, and pasted these objects into PowerPoint slides [attached]. It turned out very nice. Thank you for all your help!

DhirajPatil
14-Alexandrite
(To:bobg100x)
Announcements

Top Tags