How to do this kind of contour plot?

4 views (last 30 days)
Juan Castillo
Juan Castillo on 9 May 2018
Commented: jonas on 15 May 2018
I just want to plot a graph like this:
I know it's a contour plot, but I don't know how to do it.
I wanna plot several curves (as shown in the figure) vs another parameter, for example:
Curve 1: X-Axis --> Voltage | Y-Axis --> Current | For T = 10ºC
Curve 2: X-Axis --> Voltage | Y-Axis --> Current | For T = 20ºC
Curve 3: X-Axis --> Voltage | Y-Axis --> Current | For T = 40ºC
Curve 4: X-Axis --> Voltage | Y-Axis --> Current | For T = 60ºC
Curve 5: X-Axis --> Voltage | Y-Axis --> Current | For T = 80ºC
Somebody could help me? Thanks in advance.
  2 Comments
KSSV
KSSV on 9 May 2018
contour is the one you need. What problem you have?
Juan Castillo
Juan Castillo on 9 May 2018
Hi, thanks for your help.
Please read my last comment for more info.

Sign in to comment.

Accepted Answer

jonas
jonas on 9 May 2018
Basically you don't define data along lines but rather on a full rectangular grid. Let's say you want to plot data between x=0:10 and y=0:10.
x=0:10;
y=0:10;
[X,Y]=meshgrid(x,y)
This will give you a grid (11x11). Now define the function Z(Y,X) which you want to plot. For example:
Z=X.^2+Y.^2
[C,h]=contour(X,Y,Z)
You can also define the number of contours as a fourth argument. Finally, you can label the contours by adding:
clabel(C,h)
Hope this helps
  6 Comments
Juan Castillo
Juan Castillo on 10 May 2018
Exactly. That's what I wanna plot.
For example. The dimensions are:
Curve 1. Tº = 20ºC
X-Axis: Voltage
0
0,02
0,04
0,06
0,08
0,1
0,12
0,14
0,16
0,18
0,2
0,22
0,24
0,26
0,28
0,3
0,32
0,34
0,36
0,38
0,4
0,42
0,44
0,46
0,48
0,5
0,52
0,54
0,56
0,58
0,6
0,62
0,64
0,66
0,68
0,7
0,72
0,74
0,76
0,78
0,8
0,82
0,84
0,86
0,88
0,9
0,92
0,94
0,96
0,98
1
0,98
0,96
0,94
0,92
0,9
0,88
0,86
0,84
0,82
0,8
0,78
0,76
0,74
0,72
0,7
0,68
0,66
0,64
0,62
0,6
0,58
0,56
0,54
0,52
0,5
0,48
0,46
0,44
0,42
0,4
0,38
0,36
0,34
0,32
0,3
0,28
0,26
0,24
0,22
0,2
0,18
0,16
0,14
0,12
0,1
0,08
0,06
0,04
0,02
0
Y-Axis: Current measured
1,6785E-6
6,5565E-5
1,334E-4
2,035E-4
2,7375E-4
3,496E-4
4,2841E-4
5,1111E-4
5,9634E-4
6,7216E-4
7,7429E-4
8,6436E-4
9,6434E-4
0,00108
0,00121
0,00137
0,00149
0,00171
0,00198
0,00231
0,00272
0,00309
0,00359
0,00419
0,00498
0,00557
0,00656
0,00722
0,00801
0,00863
0,00952
0,01034
0,01112
0,01174
0,01314
0,01408
0,01473
0,01561
0,01614
0,01688
0,01806
0,01863
0,0193
0,02016
0,021
0,02143
0,02205
0,02277
0,02365
0,02436
0,0251
0,02484
0,02425
0,02372
0,02336
0,0228
0,02225
0,02166
0,02109
0,02056
0,01999
0,01944
0,0189
0,01835
0,01783
0,0173
0,01676
0,01623
0,01571
0,01519
0,01466
0,01415
0,01364
0,01312
0,01261
0,0121
0,0116
0,01109
0,01059
0,01009
0,00958
0,00909
0,00859
0,0081
0,00761
0,00712
0,00663
0,00615
0,00566
0,00518
0,0047
0,00422
0,00375
0,00327
0,0028
0,00233
0,00186
0,00139
9,2199E-4
4,5571E-4
1,168E-5
Curve 2. Tº = 40ºC
X-Axis --> Same
Y-Axis --> Same with another values
And so on. All the curves have the same dimensions.
Thanks again for your patience.
jonas
jonas on 15 May 2018
Hi again, sorry for the late reply. Based on the comments, what you want is an ordinary plot, like this:
h=plot(x,y1,...
x,y2,...
x,y3) %and so on
You can also add labels using text. Adding a colorbar to a 2d-plot is not as trivial, but it can be done by setting the line colors based on a colormap and a temperature vector, or alternatively by using something like this non-default function 3d color line (link)
This will not give you a plot identical to the one in your figure, which I believe is a surface plot (with data on a full rectangular grid). If you want to obtain similar results, then there are some different solutions. To be honest, having both colors AND clabels (as in the figure) is however unnecessary. Anyway, let me know if you still want that.

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!