![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344299/image.png)
Patch plot z-values colorbar not correct
4 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a 'patch' plot with x, y, and z-values. A 2x2 sublot is desired with a single colorbar on the right. The values of the colorbar should be from 0 to 1. However, the values in the plot are an order of magnitude off. My largest value in the upper left plot, for example, is somewhere around 0.08. But, the figure is plotting the value as 0.8.
I've attached my plotting script (below) and the variables needed (attached).
Any ideas?
Thanks.
fig = figure;
subplot(2, 2, 1)
patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0])
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4])
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2);
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--');
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':');
subplot(2, 2, 2)
patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0])
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4])
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2);
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--');
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':');
subplot(2, 2, 3)
patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0])
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4])
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2);
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--');
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':');
subplot(2, 2, 4)
patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0])
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4])
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2);
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--');
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':');
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
sgt = sgtitle('Drop Size and Velocity Distributions');
sgt.FontSize = 20;
ax = axes(fig);
yyaxis(ax, 'left');
han = gca;
han.Visible = 'off';
set(gca, 'ycolor', 'k')
han.XLabel.Visible = 'on';
han.YLabel.Visible = 'on';
xlabel('Raindrop Size [mm]')
ylabel('Raindrop Speed [m/s]')
yyaxis(ax, 'right');
c = colorbar('Position', [0.9214, 0.0935, 0.0165, 0.8147]);
c.Label.String = 'Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
han.YLabel.Visible = 'on';
采纳的回答
Adam Danz
2020-8-10
编辑:Adam Danz
2020-8-10
There are several issues to cover.
1) If you want to use 1 colorbar to represent all subplots, all subplots must have the same scale. That can be achieved using caxis(limits). However, the comment below is not correct.
"The values of the colorbar should be from 0 to 1. However, the values in the plot are an order of magnitude off."
The values that define the color in your subplots are all between ~0 and ~0.534. If you were expecting something different, the data you shared is incorrect.
After each patch() command, you need to set the caxis values to the span of the entire color range using
% These two lines only needs computed once, before plotting is done.
allColorData = [norm_DSVD_sum2019_JER, norm_DSVD_sum2019_SFL,norm_DSVD_win2019_JER,norm_DSVD_win2019_SFL];
colorRange = [min(allColorData), max(allColorData)];
% Repleat this line for each subplot
caxis(colorRange)
You'll notice that the colors now differ. Some plots will not show colors outside of a range of blues. If this is not what you want. you cannot have 1 colorbar for all subplots.
2) The extra invisible axes you're adding to control the colorbar is inefficient and prone to error. It's better to add the colorbar to any of the subplots and specify its position. But before studying this step, see the section below "Use tiledlayout instead of subplot"
To add the colorbar, put this after your last subplot
cb = colorbar('Position', [0.9214, 0.0935, 0.0165, 0.8147]);
You may want to move the subplots a bit to make room for the colorbar.
% sp is a 1x4 vector of subplot handles created by
% sp(1) = subplot(___);
% sp(2) = subplot(___);
% etc....
% Move subplots to the right by 0.05 normalized units
arrayfun(@(i)set(sp(i), 'Position', [sp(i).Position(1)-0.05, sp(i).Position(2:end)]), 1:numel(sp));
The bottom and right super-labels can be added easily using text objects.
Use tiledlayout instead of subplot
tiledlayout was introduced in r2019b and allows you to set x and y labels for all subplots. To convert your code to tiled layout,
1) After creating the figure define the layout
tlay = tiledlayout(2,2);
2) change all of your subplot commands to
sp(1) = nexttile(); % replace 1 with whatever subplot you're creating
3) There are some restrictions with the colorbar. It can only be next to 1 subplot. So, remove the 'position' property.
c = colorbar();
If the position restriction is a big problem, you'll have to add an invisible axis just for the colorbar.
ax = axes('position', [.9,.1,.08,0.75]);
caxis(colorRange)
c = colorbar('Location','East');
c.Position(3) = .015
axis(ax, 'off')
4) Then define the x and y labels
xlabel(tlay, 'Raindrop Size [mm]')
ylabel(tlay, 'Raindrop Speed [m/s]')
and replace the sgtitle command with
title(tlay, 'Normalized Drop Size and Velocity Distributions', 'FontSize', 20)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344299/image.png)
Notice that colors beyond blue are really only seen in Mesa AZ in the summer. It makes sense that rainfall in the summer will have a higher drop count than in the winter. However, it might be surprising that rainfall isn't similar between Las Cruces and Mesa in the summer on bestplaces.net (I have no idea how valid those data are).
28 个评论
Eric Escoto
2020-8-10
编辑:Eric Escoto
2020-8-10
Thanks Adam,
Wording was slighlty off theoretically, these plots could have one value that is one. the range 0 to 1 is only a normalization. From these plots you can't get an idea of the total amount of drops, only the relative amount in each bin which is what I'm comparing here. The sum of all these bins in each plot will be 1.
What you have modified seems to be exactly what I'd like but am running into some problems as I modify the script.
I'm getting this error after trying to add all color data.
Unrecognized function or variable 'allColorData'.
Error in Complete_Spectrums (line 312)
colorRange = [min(allColorData), max(allColorData)];
Can you provide the modified lines that you created in order? Maybe I'm placing them incorrectly.
Adam Danz
2020-8-10
If you want the colorbar to be normalized to [0,1] you just need to normalize allColorData to be between 0 and 1.
Eric Escoto
2020-8-11
编辑:Adam Danz
2020-8-11
It seems like I am creating the same exact plots I was before using the 'allColorData' line you've suggested.
Here's my plot and the script I'm using.
%% Plot DSVDs using 'patch' function
allColorData = [norm_DSVD_sum2019_JER, norm_DSVD_win2019_JER,norm_DSVD_sum2019_SFL,norm_DSVD_win2019_SFL];
colorRange = [min(allColorData), max(allColorData)];
%% Combined JER winter/summer 2019 NORMALIZED plot
fig = figure; % figure 6
subplot(2, 2, 1) % JER Summer 2019
patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
subplot(2, 2, 2) % JER Winter 2019
patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
subplot(2, 2, 3) % SFL Summer 2019
patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
subplot(2, 2, 4) % SFL Winter 2019
patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
sgt = sgtitle('Normalized Drop Size and Velocity Distributions');
sgt.FontSize = 20;
ax = axes(fig);
yyaxis(ax, 'left');
han = gca;
han.Visible = 'off';
set(gca, 'ycolor', 'k')
han.XLabel.Visible = 'on';
han.YLabel.Visible = 'on';
xlabel('Raindrop Size [mm]')
ylabel('Raindrop Speed [m/s]')
yyaxis(ax, 'right');
c = colorbar('Position', [0.9214, 0.0935, 0.0165, 0.8147]);
c.Label.String = 'Normalized Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
han.YLabel.Visible = 'on';
Adam Danz
2020-8-11
编辑:Adam Danz
2020-8-11
"It seems like I am creating the same exact plots I was before using the 'allColorData' line you've suggested."
The color ranges are much different. All subplots in your atttached figure range from dark blue to yellow or orange. The subplots in my answer (and your new code) are all on the same scale and only one of them gets into the yellow range.
You forgot to use caxis on the invisible axes so your colorbar isn't scalled according to colorRange. See step 3 in the "Use tiledlayout instead of subplot" section of my answer.
Eric Escoto
2020-8-11
编辑:Adam Danz
2020-8-11
Thanks Adam,
I'm still confused about what to edit in the code. Just to make sure we're using the same data, I have attached a revised file for a slight correction I noticed in my earlier lines of code.
The maximum value for each variable in order of (sum_JER, sum_SFL, win_JER, and win_SFL) should be ~0.0548, 0.0806, 0.0825, and 0.0678. The sum of each 1x1024 matrix is equal to 1.
The single colorbar should represent all values in each subplot no matter what the difference in values are for each plot.
"The color ranges are much different. All subplots in your atttached figure range from dark blue to yellow or orange. The subplots in my answer (and your new code) are all on the same scale and only one of them gets into the yellow range."
This should not be the case. If we're referencing my original plot with the 'Jet' colorscheme that goes from [0,1] then all of the colors in all of the plots will not be anything other than shades of blue because at a value of 0.1 in colorbar we are still in blue and my actual normalized values are less than 0.1.
With this in mind I may want to change the colorbar range to better represent the actual data range (maybe the callout will automatically do this?)
Can you provide a modified script of my code above with the corrections in line compared to what you have done in segments? I am getting lost on what to do with all of the corrections (I've not used tiledlayout) and perhaps this can help.
Actually, here's what I have written so far with an error message of invlaid arguments using nexttile. Note that I'm just commenting out the subplot commands and other things you noted to modify so I donlt lose them if this doesnt work.
%% Plot DSVDs using 'patch' function
allColorData = [norm_DSVD_sum2019_JER, norm_DSVD_win2019_JER,norm_DSVD_sum2019_SFL,norm_DSVD_win2019_SFL];
colorRange = [min(allColorData), max(allColorData)];
%% Combined JER winter/summer 2019 NORMALIZED plot
fig = figure; % figure 6
tlay = tiledlayout(2, 2);
% subplot(2, 2, 1) % JER Summer 2019
sp(1) = nexttile(patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off'));
% patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 2) % JER Winter 2019
sp(2) = nexttile(patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off'));
% patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 3) % SFL Summer 2019
sp(3) = nexttile(patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off'));
% patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 4) % SFL Winter 2019
sp(4) = nexttile(patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off'));
% patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
sgt = sgtitle('Normalized Drop Size and Velocity Distributions');
sgt.FontSize = 20;
ax = axes(fig);
yyaxis(ax, 'left');
han = gca;
han.Visible = 'off';
set(gca, 'ycolor', 'k')
han.XLabel.Visible = 'on';
han.YLabel.Visible = 'on';
xlabel('Raindrop Size [mm]')
ylabel('Raindrop Speed [m/s]')
yyaxis(ax, 'right');
c = colorbar();
% c = colorbar('Position', [0.9214, 0.0935, 0.0165, 0.8147]);
c.Label.String = 'Normalized Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
han.YLabel.Visible = 'on';
Adam Danz
2020-8-11
I've edited your comments to format your code. In furture comments, please use the [>] button in the editor to format code in your comments (more info).
"The single colorbar should represent all values in each subplot no matter what the difference in values are for each plot."
That's what my answer does but the range of values in your vectors do not span from 0 to 1. In my answer, the colors in all of the subplots are defined by the colors in the colorbar.
"I may want to change the colorbar range to better represent the actual data range "
Again, that's exactly what my answer is doing. In the original data you shared, the norm_DSVD.... values all spaned from nearly 0 to about 0.534 and if you look at the colorbar in the plot in my answer, you'll see that it also spans from 0 to 0.534.
So, it's unclear whether you're saying that the plot in my answer, given the data, is not what you're aiming for --or- that you're having trouble adapting your code to my solution.
If my solution is not what you're looking for, then the meaning of the norm_DSCD_... values is not clear.
- Why does it matter that they sum to 1?
- What should the color represent?
- Should each subplot show colors that cover the full range of the colorbar?
Perhaps you want to normalize each vector to span from 0 to 1.
z = (norm_DSVD_sum2019_JER - min(norm_DSVD_sum2019_JER)) / range(norm_DSVD_sum2019_JER);
or maybe you want the cumulative sum
z = cumsum(norm_DSVD_sum2019_JER, 'omitnan');
If my solution is what you're looking for, then here are some changed that are needed to the code in your previous comment.
- nexttile does not have any input arguments. It literally just adds a new subplot according to your tiledlayout. See examples. So, you'll need to remove the patch() commands from the nexttile inputs and put them on a separate line after nexttile(). That's what my step #2 explains in my answer under "Use tiledlayout instead of subplot".
- Then you need to follow step #3 in that section - the 5 lines at the end. Note that I'm placing the invisible axes much differently than you are. Critically, I'm also applying caxis to it.
Eric Escoto
2020-8-11
The colorbar should span from the lowest to highest value across all plots. [0, max]. You've noted that the max in each plot is different. That is correct. I'd like a single colorbar to go from [0, max(of any one plot whichever that may be)]. The value of 0.05 in one plot should be the same color as the value of 0.05 in another plot. some plots would not show a color value greater than 0.05 because they simply dont have that value in the vector.
Each vector itself sums to 1 because they have been normalized according to the total amount of drops in each season and at each site. The total amount of drops recorded is different for each location/season. Making sure they sum to one means that the normalization is correct.
The color represents that portion of the total drops in each bin accrding to the normalization. The color represents the concentration of total drops in each square of the plot represented by size/speed classes on the axis from the X, and Y variables I provided.
I suppose the colorbar should simply span the range of 0 to the maximum value across all plots. In this dataset that value is ~0.0825 (in, 'win_JER' matrix).
Adam Danz
2020-8-11
编辑:Adam Danz
2020-8-14
" I'd like a single colorbar to go from [0, max(of any one plot whichever that may be)]"
Impossible.
You can't have 1 colorbar for 4 different scales. "Canary Yellow" can only mean 1 thing. "Royal Blue" can only mean 1 thing. That's why the colorbar in my answer spans the entire range of all norm_DSVD... values.
" The value of 0.05 in one plot should be the same color as the value of 0.05 in another plot. some plots would not show a color value greater than 0.05 because they simply dont have that value in the vector."
That's exactly what my answer does. That also differs from the first quoted sentence above. For example, let's say the max of subplot 1 is 0.005, the max of subplot 2 is 0.01, subplot 3 max is 0.05 and subplot 4 max is 0.1; Then the colorbar is my answer will span from 0.005 to 0.1 since those are the global min and max values.
"The color represents that portion of the total drops in each bin accrding to the normalization. "
If you'd like, instead of using caxis(colorRange) on each subplot, you could use caxis([0,1]). However, since your max colorbar value is very low, the result will be that all colors go down to blue since the range is increase to 1. Note that the current version, using caxis(colorRange), is just as fine. The only difference is that the colorbar will cut off at the max value rather than 1. The interpretation is still exactly the same.
"I suppose the colorbar should simply span the range of 0 to the maximum value across all plots"
That's exactly what my answer is doing. Your smallest norm_DSVD... value isn't quite equal to zero (it's very very close). If you wanted exactly 0, replace
colorRange = [min(allColorData), max(allColorData)];
with
colorRange = [0, max(allColorData)];
Again, it's unclear whether the problem is with my answer (which, it could be, if the interpretation of the values differs from my understanding), or if the problem is in your implementation of my answer.
Eric Escoto
2020-9-5
编辑:Eric Escoto
2020-9-5
Hi Adam (or anyone),
I have tried these lines (finally) and am not getting results. I get an error message regarding 'nexttile', stating it is an invalid argument. Any ideas?
I've checked to make sure line items 1-4 (above in Use tiledlayout instead of subplot) have been completed. It looks okay.
Adam Danz
2020-9-6
Make sure you're using Matlab r2019b or later. Earlier versions do not support tiled layout.
Could you share the entire error message as well as the line that is generating the error?
Eric Escoto
2020-9-7
Sure! I'm using 2020a. Below is the error message.
Error using nexttile
Invalid arguments.
Error in Complete_Spectrums (line 397)
sp(1) = nexttile(patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off'));
Adam Danz
2020-9-7
编辑:Adam Danz
2020-9-9
See the end of my comment above (<-- click link). Specifically, the part that starts with "1. nexttile does not have any input arguments".
Eric Escoto
2020-9-8
I've made changes to the nexttile as per part three. However, the color scale is still not working correctly. The figure that is created is below.
allColorData = [norm_DSVD_sum2019_JER, norm_DSVD_win2019_JER,norm_DSVD_sum2019_SFL,norm_DSVD_win2019_SFL];
colorRange = [min(allColorData), max(allColorData)];
fig = figure; % figure 6
tlay = tiledlayout(2, 2);
% subplot(2, 2, 1) % JER Summer 2019
sp(1) = nexttile; %(patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off'));
patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 2) % JER Winter 2019
sp(2) = nexttile, %(patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off'));
patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 3) % SFL Summer 2019
sp(3) = nexttile, %(patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off'));
patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
% subplot(2, 2, 4) % SFL Winter 2019
sp(4) = nexttile, %(patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off'));
patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
% sgt = sgtitle('Normalized Drop Size and Velocity Distributions');
% sgt.FontSize = 20;
title(tlay, 'Normalized Drop Size and Velocity Distributions', 'FontSize', 20)
ax = axes(fig);
yyaxis(ax, 'left');
han = gca;
han.Visible = 'off';
set(gca, 'ycolor', 'k')
han.XLabel.Visible = 'on';
han.YLabel.Visible = 'on';
xlabel(tlay, 'Raindrop Size [mm]')
ylabel(tlay, 'Raindrop Speed [m/s]')
yyaxis(ax, 'right');
c = colorbar();
% c = colorbar('Position', [0.9214, 0.0935, 0.0165, 0.8147]);
c.Label.String = 'Normalized Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
han.YLabel.Visible = 'on';
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358051/image.jpeg)
Adam Danz
2020-9-9
That's because of this unnecessary axis which I mentioned in step #2 in the upper half of my answer.
ax = axes(fig);
yyaxis(ax, 'left');
han = gca;
han.Visible = 'off';
set(gca, 'ycolor', 'k')
han.XLabel.Visible = 'on';
han.YLabel.Visible = 'on';
xlabel(tlay, 'Raindrop Size [mm]')
ylabel(tlay, 'Raindrop Speed [m/s]')
yyaxis(ax, 'right');
Remove that and follow step #4 in the bottom half of my answer instead.
Eric Escoto
2020-9-9
Got it! Thanks!
With all that done, I've got a small issue to correct with regards to the plot itself.
There seems to be too much space between the left and right columns of plots, and I'd like to reduce it a little. What callout can help with this? I think reducing that white space by half could work better. Basically a portion of the colorbar label is cut off.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358417/image.bmp)
Eric Escoto
2020-9-9
编辑:Eric Escoto
2020-9-9
That worked to reduce the space, however, the text on the colorbar is still cropped out.
I used Tilespacing = none, and Padding = normal. Is the colorbar location just too far out to the right?
Here's the figure.
Edit: I just found this question in the community. Didn't seem to be resolved though.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358429/image.bmp)
Adam Danz
2020-9-9
I see. In my version (in my answer) the colorbar ticks only have 1 decimal place so the cb legend isn't pushed out of view. Your have 2 dp and that's probably causing the problem. Have you tried placing the cb ylabel on the left of the cb instead of the right? I wonder if that would fix it.
With subplots, we can adjust the position of the cb but with tiledlayout we cannot, at least in r2020a and earlier. The advice in the answer you linked to is for regular subplots, not tiledlayout plots which were introduced relatively recently.
However, you probably can reposition the cb ylable using
cbYlab = ylabel(cb, 'Normalized....Count'); % where cb is your colorbar handle
cbYlab.Position(1) = ____
Eric Escoto
2020-9-10
I tried doing some positioning changes, but the figure is still a little bit off near the colorbar/plot interface on the right.
Could you look at the last lines of my figure callout? I'm not sure how to use the cb lines you provided.
%% Combined JER winter/summer 2019 NORMALIZED plot
fig = figure; % figure 6
tlay = tiledlayout(2, 2, 'TileSpacing', 'none', 'Padding', 'normal');
sp(1) = nexttile; % JER Summer 2019
patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(2) = nexttile; % JER Winter 2019
patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(3) = nexttile; % SFL Summer 2019
patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(4) = nexttile; % SFL Winter 2019
patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Location', 'Southeast'); %'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
ax = axes('position', [.9,.1,.08,0.75]);
caxis(colorRange)
c = colorbar('Location','West');
c.Position(3) = .0125
axis(ax, 'off')
%c = colorbar();
c.Label.String = 'Normalized Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
%han.YLabel.Visible = 'on';
%cbYlab = ylabel(c, 'Normalized Raindrop Count'); % where cb is your colorbar handle
%cbYlab.Position(1) =
xlabel(tlay, 'Raindrop Size [mm]')
ylabel(tlay, 'Raindrop Speed [m/s]')
title(tlay, 'Normalized Drop Size and Velocity Distributions', 'FontSize', 20)
Adam Danz
2020-9-10
This
cbYlab = ylabel(c, 'Normalized Raindrop Count');
is the same as what you're doing above
c.Label.String = 'Normalized Raindrop Count';
except that my version stores the handle to the y-axis-label.
What problems are you having with that line? After running that line, look at
cbYlab.Position
It will be a 1x3 vector where the first and 2nd values show the horizontal and vertical position of the y-axis label. You can shift the position leftward by subtracting a little from cbYlab.Position(1) using something like
cbYlab.Position(1) = cbYlab.Position(1)*.95; % ie, 95% of its current position
Eric Escoto
2020-9-10
I'm seeing the label itself move, but the cb itself is too close to the plots. Part of the text is cut out. Here's the figure I'm making. Sorry for the fuzzyniess.
For future refernce, whats the best way to inset a figure here? i usually save the .fig as a .jpg but it comes out either to large or too small.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358984/image.jpeg)
Adam Danz
2020-9-10
编辑:Adam Danz
2020-9-10
Well, it looks like you're back to using the invisible overlaying axis.
I still have the same response to that as above
If you put together a minimal working example (MWE) of 4 tiled plots using tiled layout and a colorbar with 2 decimal places along the y axis, I can play around with it. The MWE does not need to contain any data. What's important is that your tiled layout spacing is preserved in the MWE.
Eric Escoto
2020-9-10
编辑:Eric Escoto
2020-9-10
I'm a bit unsure how to go about putting together a MWE. It'll help me if I keep with the script I'm working with.
What I've done now is remove axis position callout and simply have the c = colorbar(); callout then associated lines below as shown. Everything that seems to be dealing with my colorbar is after the commented out ax line (%ax = axes('position', [.9,.1,.08,0.75]);).
What's intersting is that if I make the figure window larger, the text is then seen and all seems okay.
When I use the print command (also below) the figure that's printed is the one without enlarging the .fig window.
%% Combined JER winter/summer 2019 NORMALIZED plot
fig = figure; % figure 6
tlay = tiledlayout(2, 2, 'TileSpacing', 'none', 'Padding', 'normal');
sp(1) = nexttile; % JER Summer 2019
patch(X, Y, norm_DSVD_sum2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(2) = nexttile; % JER Winter 2019
patch(X, Y, norm_DSVD_win2019_JER,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Las Cruces, NM', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(3) = nexttile; % SFL Summer 2019
patch(X, Y, norm_DSVD_sum2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Summer 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
sp(4) = nexttile; % SFL Winter 2019
patch(X, Y, norm_DSVD_win2019_SFL,'HandleVisibility','off');
caxis(colorRange)
title('Winter 2019, Mesa, AZ', 'FontSize', 12)
xlim([0 8])
ylim([0 11])
xticks([0 1.25 2.5 5.0 8.0 10.0 20.0 26.0]) % These ticks delineate changes in class spread.
yticks([0 1.0 2.0 4.0 8.0 11.0 16.0 22.4]) % These ticks delineate changes in class spread.
grid off
hold on
p1 = plot(X, vD_AfGK, 'r', 'LineWidth', 2); % This plots the Atlas empirical v(D) line from Gunn-Kinzer's data.
p2 = plot(X, vD_AU, 'r--', 'Linewidth', 2, 'LineStyle', '--'); % This plots the Atlas and Ulbrich, 1977 v(D) line.
p3 = plot(X, vD_VD, 'r', 'Linewidth', 2, 'LineStyle', ':'); % This plots the van Dijk et. al. (2002) v(D) line.
lgd = legend([p1(1) p2(1) p3(1)],'Atlas et. al., 1973', 'Atlas and Ulbrich, 1977', 'van Dijk et. al., 2002', 'Location', 'Southeast'); %'Position', [.72 .12 .14 .1]);
lgd.FontSize = 6.5;
lgd.Title.String = 'Droplet Size/Velocity Relationships';
%ax = axes('position', [.9,.1,.08,0.75]);
caxis(colorRange)
%c = colorbar('Location','Westoutside');
%c.Position(3) = .0125
%axis(ax, 'off')
c = colorbar();
c.Label.String = 'Normalized Raindrop Count';
c.Label.FontSize = 12;
colormap('jet')
%han.YLabel.Visible = 'on';
%cbYlab = ylabel(c, 'Normalized Raindrop Count'); % where cb is your colorbar handle
%cbYlab.Position(1) = cbYlab.Position(1)*.95;
xlabel(tlay, 'Raindrop Size [mm]')
ylabel(tlay, 'Raindrop Speed [m/s]')
title(tlay, 'Normalized Drop Size and Velocity Distributions', 'FontSize', 20)
print(gcf, '/Users/DSVDs_foursubplots_2.bmp', '-dpng', '-r800');
Adam Danz
2020-9-10
编辑:Adam Danz
2020-9-10
Unfortunately I cannot run your script since I don't have the variable definitions.
To make a MWE you just need to eliminate anything in your code that calls your variables and maintain the parts that produce the tiled layout and colorbar with the exact spacing you're using. The colors and other details aren't important. It should be able to run if I copy and paste it into my workspace.
Example (run this):
figure()
tl = tiledlayout(2,2);
nexttile
nexttile
nexttile
nexttile
cb = colorbar();
ylim(cb, [0, .5])
cb.Ticks = [.111:.1:.5]; % 3 decimal places
yl = ylabel(cb, 'Label');
The idea is to vastly reduce the amount of time needed for me (or any other volunteer) to reproduce the problem. Otherwise, there's way too much time needed to sift through a bunch of code that has nothing to do with the spacing problems and to guess what variables mean, etc. Sometimes MWEs take time to put together but I can assure you that the amount of time saved on our ends is much greater than the time it takes to create a MWE. With a functional example that reproduces the problem on my end, this could have been solved hours ago.
Adam Danz
2020-9-10
编辑:Adam Danz
2020-9-10
Have you thought about moving the legend to the upper axis and then putting the colorbar inside the bottom axis? There's lots of open space on the right side of your plots.
Also, the legend should be in the south east corner to avoid overlapping the small amount of data in the north east corner.
更多回答(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!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)