I am using the filled contour plot function (contourf) to generate a series of contour plots. I am using a vector to define the contour levels.

Lets say that for 1000 sets of data with Z values ranging from 0-100, I am making a contour plot for each data set. Each contour plot should have potentially 10 levels, predefined, based on the bottom 10% of data values up to the top 10% of values. But if a particular set of data only contains values in the middle 50%, (from about 25-75) I want the color to represent this as well as the contour lines.

Currently, each plot goes from blue to red regardless of the vector defined levels. I want blue to represent an absolute Z value across all my contour plots, instead of being redefined per plot.

All help is appreciated.

Thank you.

I believe that I have found a way to do this. Consider the following example.

1. Suppose Z is your matrix of data and it includes values in the interval [10,34]. However, you want your colormap to reflect values in the interval [0,50].

2. Save Z under another name: Z2=Z.

3. Set one element of Z equal to 0 and another element of Z equal to 50.

4. Create a contour map using Z. This contour map has the colormap you desire. However, it does not reflect your data because of the changes made in step 3.

5. Now use the "hold on" command and then create another contour map using Z2. This will yield a contour map of your data with the colormap you desire.

Here's the code. (Adding the lines maked with "*****" achieves the desired outcome.)

close all

clear all

Z = [10 11 12 13 14

15 16 17 18 19

20 21 22 23 24

25 26 27 28 29

30 31 32 33 34 ];

[X,Y] = meshgrid(1:1:5);

hf=figure;

levels = [0 5 10 15 20 25 30 35 40 45];

Z2=Z % *****

Z(1,1)=1; Z(1,2)=50; % *****

contourf(Z,levels);

hold on; % *****

contourf(Z2,levels); % *****

1. Suppose Z is your matrix of data and it includes values in the interval [10,34]. However, you want your colormap to reflect values in the interval [0,50].

2. Save Z under another name: Z2=Z.

3. Set one element of Z equal to 0 and another element of Z equal to 50.

4. Create a contour map using Z. This contour map has the colormap you desire. However, it does not reflect your data because of the changes made in step 3.

5. Now use the "hold on" command and then create another contour map using Z2. This will yield a contour map of your data with the colormap you desire.

Here's the code. (Adding the lines maked with "*****" achieves the desired outcome.)

close all

clear all

Z = [10 11 12 13 14

15 16 17 18 19

20 21 22 23 24

25 26 27 28 29

30 31 32 33 34 ];

[X,Y] = meshgrid(1:1:5);

hf=figure;

levels = [0 5 10 15 20 25 30 35 40 45];

Z2=Z % *****

Z(1,1)=1; Z(1,2)=50; % *****

contourf(Z,levels);

hold on; % *****

contourf(Z2,levels); % *****

1. Plotting 3D points on 2D-contour plots with colors indicating z values

2. Contour Plot / Plot Range / Contour Scaling

3. Plotting a Colour lined plot in Matlab

4. Adding a scatter plot to a contour plot

5. How to plot contour plot with random numbers

6. Plotting z against x and y (contour plot)

7. How does Mathematica create contour plots (or density plots)?

8. Plotting things at the base of a contour plot

9. plotting a 2D line on top of a contour plot

10. Label plot lines like a contour plot

11. AW: Plotting a contour plot with cylindrical co-ordinates

12. plotting a matrix into a contour plot

13. Moving the contour plot with the surfc plot fu

14. mapping a contour plot onto a surface plot

15. Moving the contour plot with the surfc plot function

3 post • Page:**1** of **1**