Contour plot
11 views (last 30 days)
Show older comments
Hi,
How can I make contour plots that do not 'interpolate'? For example, suppose I have the matrix a = [0 0 0 0; 0 1 1 0; 0 1 1 0; 0 0 0 0], which I would like to look like a square when I use contour(a,1) (the ,1 is used in order to have only one contour line). However, Matlab outputs an octagon-like shape, i.e. it kind of rounds the corners. I have seen that certain Matlab based software can do such contour plots, but I can't access the code and haven't been able to get it to work myself. Any help would be greatly appreciated!
Thanks,
Falk
0 Comments
Accepted Answer
Sean de Wolski
on 24 May 2011
Multiple calls to line. You'll have to write some type of wrapper function but it should be doable.
More Answers (4)
Arnaud Miege
on 24 May 2011
Try this:
contour(a,[1 1])
HTH,
Arnaud
2 Comments
Arnaud Miege
on 24 May 2011
It seems that the contour matrix is computed automatically and is read-only, so you can't edit it - at least I haven't found a way to do it. Maybe contour isn't the right way to go about it?
Sean de Wolski
on 24 May 2011
If instead of a contour plot you could deal with an edge, this might work:
Lrgb = label2rgb(bwperim(kron(a,ones(10)))); %expanding with 10x10 to create an edge imshow(Lrgb) %IPT required
Matt Tearle
on 24 May 2011
Massive hack that works in this case (not sure how generalizable it will be to whatever your application is):
a(a==0) = NaN;
mesh(a)
set(gca,'View',[0,90],'XGrid','off','YGrid','off')
2 Comments
Matt Tearle
on 25 May 2011
Oh, no, my bad. I hadn't read the comments on Arnaud's answer, sorry. Looks like you'll have to write your own routine to do multiple line calls, as Sean suggests.
Yusuf Yilmaz
on 10 Nov 2021
Hi,
It is possible to put different line style on each line in contourf command or not If so, how ?
Thanks in advance
0 Comments
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!