If the above polar or spider plot is not possible (or too complicated), I would settle for a similar type of chart but in bar format. So each x axis value has a bar that stretches from datamin to datamax (Kind of like a box plot but without all the whiskers and statistical graphics, just a min and max). Has anyone done this before?
How do I plot value ranges in polar or spider
9 次查看(过去 30 天)
显示 更早的评论
Need to plot data using a Spider or Polar chart. As of 1/18/2017, existing MathWorks File Exchange files do not fit the requirements I've outlined below
Requirements:
- Each axis needs to be independent (axis min and axis max values for each axis is different).
- Each axis shows the axis range (axis min and axis max, option to turn this on/off)
- Data point values shown on plot (option to turn this on/off)
- Each axis must plot the range of the data. Example data set to show what I mean:
- Axis Label1: min=0, max=10, datamin=1, datamax=7.
- Axis Label2: min=500, max=578, datamin=515, datamax=545.
- Axis Label3: min=0, max=100, datamin=45, datamax=75.
- .
- .
- .
- Axis Labeln: min=x, max =y, datamin=a, datamax=b.
So, the result is a polar or spider plot that has the areas in between datamin and datamax for each axis filled in with a particular color (see image). The image example shows the plot having only 6 axes, but I will need more.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159481/image.jpeg)
More Info For Context:
- Once I can generate the plot described above (and shown in attached) for 1 data set of min and max values,
- I plan to create other plots using other data sets,
- then I overlay all the plots to determine what areas (range of values in each axis) that are not covered
I can't find any solutions that fills a range of data per axis. All the solutions fill each axis in the plot from center of plot to the data point. I've also tried to modify existing files in the exchange, but I cant figure out how to edit it to make it do what I want.
采纳的回答
Kelly Kearney
2017-1-18
Given all your specifics, I think it would be much easier to just build the plot manually, rather than try to use any FEX entries. You really just need to do a bunch of polar-to-cartesian conversions to plot this:
% Your data (axis limits and data limits)
lims = [...
0 10 1 7
500 578 515 545
0 100 20 75];
nax = size(lims,1);
axlim = lims(:,1:2);
datalim = lims(:,3:4);
% r and theta for data points
axtheta = linspace(0, 2*pi, nax+1);
axtheta = axtheta(end-1:-1:1)';
rdata = nan(size(datalim));
for iax = 1:nax
rdata(iax,:) = interp1(axlim(iax,:), [0 1], datalim(iax,:));
end
% Outer and inner rings
xout = rdata(:,2) .* cos(axtheta);
yout = rdata(:,2) .* sin(axtheta);
xout = [xout; xout(1)];
yout = [yout; yout(1)];
xin = rdata(:,1) .* cos(axtheta);
yin = rdata(:,1) .* sin(axtheta);
xin = [xin; xin(1)];
yin = [yin; yin(1)];
% Labels (axis limits and names)
lbl1 = arrayfun(@(lo,hi) sprintf('(%d,%d)', lo, hi), axlim(:,1), axlim(:,2), 'uni', 0);
lbl2 = cellstr(num2str((1:nax)', 'Label %d'));
% The shaded area
xpoly = [xout; xin(end:-1:1); xout(1)];
ypoly = [yout; yin(end:-1:1); yout(1)];
% Plot data
h.ax = axes('xlim', [-1 1], 'ylim', [-1 1], 'dataaspectratio', [1 1 1], 'visible', 'off');
hold(h.ax, 'on');
h.poly = patch(xpoly, ypoly, 'r');
set(h.poly, 'edgecolor', 'none', 'facealpha', 0.2);
h.outline = plot(xout, yout, 'r', xin, yin, 'r');
h.txt = text([xin(1:end-1); xout(1:end-1)], [yin(1:end-1); yout(1:end-1)], cellstr(num2str(datalim(:))));
% Plot axes
h.axline = plot([zeros(1,nax); cos(axtheta')], [zeros(1,nax); sin(axtheta')], '--k');
h.axedge = plot(cos(axtheta([1:end 1])), sin(axtheta([1:end 1])), ':k');
h.axlbl1 = text(cos(axtheta'), sin(axtheta), lbl1, 'fontsize', 8);
h.axlbl2 = text(1.2*cos(axtheta'), 1.2*sin(axtheta'), lbl2, 'horiz', 'center', 'vert', 'top');
isleft = cos(axtheta) < 1;
set(h.axlbl1(isleft), 'horiz', 'right');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176742/image.png)
Repeat the rdata, xout, xin, and xpoly calculations for each of your datasets (you might want to wrap that part in a function if you're going to reuse it a lot.)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!