plotting with pcolor instead of imagesc but with a similar coloring algorithm
27 次查看(过去 30 天)
显示 更早的评论
I am trying to plot a dataset with variable y-axis values. I used pcolor to make this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166353/image.png)
As you can see it interpolated colors at some regions that there is no data (i.e. around 7:00 and 15:00).
Is there any way to fix this in pcolor or surf functions and somehow get them to color the pixels in a similar way as imagesc (based on center values not corners)?
I can't use image or imagesc functions because I need logarithmic y axis and when I use those plotting routines I get the error that is discussed here.
0 个评论
回答(1 个)
Shruti Shivaramakrishnan
2017-7-31
There are functions available in MATLAB which can perform 1-D, 2-D, or 3-D data interpolation. The function names are 'interp1', 'interp2' and 'interp3'. Depending on how many variables you have, you can try using the corresponding function to interpolate your data before using 'pcolor' to create the pseudocolor plot.
It may be a good idea to check out the section titled 'Interpolation' in the doc page below:
If you are looking at smoothing the graph, the following answer's post might help: https://www.mathworks.com/matlabcentral/answers/86013-pcolor-how-to-smooth
"shading interp" command might be helpful here as well: https://www.mathworks.com/help/matlab/ref/shading.html
This third-party file-exchange function might also be helpful: https://www.mathworks.com/matlabcentral/fileexchange/35601-sanepcolor-varargin-
There is a MATLAB Example that can help with offset data: https://www.mathworks.com/examples/matlab/community/20093-offsets-and-discarded-data-via-pcolor-and-surf
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!