- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在子图的底部添加一个图例(2 x 2):
正如您所看到的,由于我手动调整了第二行中的图表,因此被挤压了一点。
是否有像 sublegend(...) 这样的函数,或者它是否涉及大量编码?
来源
这个脚本产生一个类似的子图:
%weights/weightsMV are 3 x 30 matrices
ticker = {'A','B','C'};
weights = [0.764602615068780,0.762329415005434,0.760055503116586,0.757781382654864,0.755508517683302,0.753234375934985,0.750960611173760,0.748686727917457,0.746413866211585,0.744140033854148,0.738367347277555,0.699505907957926,0.660644468638298,0.621783029318668,0.582921589999040,0.544060150679411,0.505198711359782,0.466337272040153,0.427475832720524,0.388614393400895,0.349752954081266,0.310891514761637,0.272030075442009,0.233168636122380,0.194307196802750,0.155445757483122,0.116584318163493,0.0777228788438641,0.0388614395242353,4.10026844681349e-12;0.235397384931220,0.211630038764514,0.187863021792451,0.164096524898550,0.140329000457761,0.116562305396725,0.0927953654491337,0.0690285024746061,0.0452609759124620,0.0214940798746062,0,5.55111512312733e-17,0,5.55111512312746e-17,0,3.70817036264992e-30,4.73852588619852e-30,5.76503212536727e-30,5.38827593281225e-30,2.64267976542398e-18,5.69348240589127e-18,8.74428504635863e-18,1.17950876868260e-17,0,2.75245082116940e-18,1.22032105779319e-17,9.15240793746451e-18,6.10160529699720e-18,6.10160531305980e-18,1.30251232759518e-10;1.10307850379949e-18,0.0260405462300517,0.0520814750909638,0.0781220924465861,0.104162481858937,0.130203318668290,0.156244023377106,0.182284769607937,0.208325157875953,0.234365886271246,0.261632652722445,0.300494092042074,0.339355531361703,0.378216970681332,0.417078410000960,0.455939849320589,0.494801288640218,0.533662727959847,0.572524167279476,0.611385606599105,0.650247045918734,0.689108485238363,0.727969924557991,0.766831363877620,0.805692803197249,0.844554242516878,0.883415681836507,0.922277121156136,0.961138560475765,0.999999999865655]
weightsMV = [0.304769232969962,0.313206616760582,0.299868860275947,0.286531103791370,0.273193347306773,0.259855590822158,0.246517834337581,0.233180077852984,0.219842321368369,0.206504564883792,0.193166808399157,0.179829051914561,0.166491295429983,0.153153538945368,0.139815782460772,0.126478025976194,0.113140269491579,0.0998025130069825,0.0864647565224054,0.0731270000377706,0.0597892435531935,0.0464514870685779,0.0331137305839816,0.0197759740993660,0.00643821761478891,0,0,0,0,0;0.695230767030038,0.658949751075843,0.636813620182365,0.614677489288983,0.592541358395569,0.570405227502122,0.548269096608740,0.526132965715326,0.503996834821880,0.481860703928497,0.459724573035019,0.437588442141605,0.415452311248223,0.393316180354776,0.371180049461362,0.349043918567980,0.326907787674534,0.304771656781119,0.282635525887737,0.260499394994259,0.238363264100876,0.216227133207430,0.194091002314016,0.171954871420570,0.149818740527187,0.123200747149645,0.0924005603621983,0.0616003735748407,0.0308001867873497,0;0,0.0278436321635749,0.0633175195416878,0.0987914069196473,0.134265294297658,0.169739181675720,0.205213069053679,0.240686956431690,0.276160843809752,0.311634731187711,0.347108618565824,0.382582505943834,0.418056393321794,0.453530280699856,0.489004168077866,0.524478055455826,0.559951942833888,0.595425830211898,0.630899717589858,0.666373604967971,0.701847492345930,0.737321379723992,0.772795267102002,0.808269154480064,0.843743041858024,0.876799252850355,0.907599439637802,0.938399626425159,0.969199813212650,1];
figure('name','Weights as 3D Plot');
subplot(2, 2, 1);
plot3([weights(1, :)' weightsMV(1, :)'], [weights(2, :)' weightsMV(2, :)'], [weights(3, :)', weightsMV(3, :)']);
grid on;
xlabel(ticker(1));
ylabel(ticker(2));
zlabel(ticker(3));
subplot(2, 2, 2);
plot([weights(2, :)' weightsMV(2, :)'], [weights(3, :)' weightsMV(3, :)'])
xlabel(ticker(2));
ylabel(ticker(3));
grid on
subplot(2, 2, 3);
plot([weights(1, :)' weightsMV(1, :)'], [weights(3, :)' weightsMV(3, :)'])
xlabel(ticker(1));
ylabel(ticker(3));
grid on
subplot(2, 2, 4);
plot([weights(1, :)' weightsMV(1, :)'], [weights(2, :)' weightsMV(2, :)'])
xlabel(ticker(1));
ylabel(ticker(2));
title('Top');
grid on
legend('TS1', 'TS2', 'Location', 'SouthOutside');
最佳答案
我已经设法用尽可能少的代码编写了一个与附件相似的脚本。图例元素的并排对齐很棘手,您将需要外部脚本。我使用了 gridLegend,可在 Matlab Central File Exchange 上获得:
http://www.mathworks.com/matlabcentral/fileexchange/29248-gridlegend-a-multi-column-format-for-legends
这是您的代码,经过修改后可以绘制类似于图像上的图例:
%weights/weightsMV are 3 x 30 matrices
ticker = {'A','B','C'};
weights = [0.764602615068780,0.762329415005434,0.760055503116586,0.757781382654864,0.755508517683302,0.753234375934985,0.750960611173760,0.748686727917457,0.746413866211585,0.744140033854148,0.738367347277555,0.699505907957926,0.660644468638298,0.621783029318668,0.582921589999040,0.544060150679411,0.505198711359782,0.466337272040153,0.427475832720524,0.388614393400895,0.349752954081266,0.310891514761637,0.272030075442009,0.233168636122380,0.194307196802750,0.155445757483122,0.116584318163493,0.0777228788438641,0.0388614395242353,4.10026844681349e-12;0.235397384931220,0.211630038764514,0.187863021792451,0.164096524898550,0.140329000457761,0.116562305396725,0.0927953654491337,0.0690285024746061,0.0452609759124620,0.0214940798746062,0,5.55111512312733e-17,0,5.55111512312746e-17,0,3.70817036264992e-30,4.73852588619852e-30,5.76503212536727e-30,5.38827593281225e-30,2.64267976542398e-18,5.69348240589127e-18,8.74428504635863e-18,1.17950876868260e-17,0,2.75245082116940e-18,1.22032105779319e-17,9.15240793746451e-18,6.10160529699720e-18,6.10160531305980e-18,1.30251232759518e-10;1.10307850379949e-18,0.0260405462300517,0.0520814750909638,0.0781220924465861,0.104162481858937,0.130203318668290,0.156244023377106,0.182284769607937,0.208325157875953,0.234365886271246,0.261632652722445,0.300494092042074,0.339355531361703,0.378216970681332,0.417078410000960,0.455939849320589,0.494801288640218,0.533662727959847,0.572524167279476,0.611385606599105,0.650247045918734,0.689108485238363,0.727969924557991,0.766831363877620,0.805692803197249,0.844554242516878,0.883415681836507,0.922277121156136,0.961138560475765,0.999999999865655]
weightsMV = [0.304769232969962,0.313206616760582,0.299868860275947,0.286531103791370,0.273193347306773,0.259855590822158,0.246517834337581,0.233180077852984,0.219842321368369,0.206504564883792,0.193166808399157,0.179829051914561,0.166491295429983,0.153153538945368,0.139815782460772,0.126478025976194,0.113140269491579,0.0998025130069825,0.0864647565224054,0.0731270000377706,0.0597892435531935,0.0464514870685779,0.0331137305839816,0.0197759740993660,0.00643821761478891,0,0,0,0,0;0.695230767030038,0.658949751075843,0.636813620182365,0.614677489288983,0.592541358395569,0.570405227502122,0.548269096608740,0.526132965715326,0.503996834821880,0.481860703928497,0.459724573035019,0.437588442141605,0.415452311248223,0.393316180354776,0.371180049461362,0.349043918567980,0.326907787674534,0.304771656781119,0.282635525887737,0.260499394994259,0.238363264100876,0.216227133207430,0.194091002314016,0.171954871420570,0.149818740527187,0.123200747149645,0.0924005603621983,0.0616003735748407,0.0308001867873497,0;0,0.0278436321635749,0.0633175195416878,0.0987914069196473,0.134265294297658,0.169739181675720,0.205213069053679,0.240686956431690,0.276160843809752,0.311634731187711,0.347108618565824,0.382582505943834,0.418056393321794,0.453530280699856,0.489004168077866,0.524478055455826,0.559951942833888,0.595425830211898,0.630899717589858,0.666373604967971,0.701847492345930,0.737321379723992,0.772795267102002,0.808269154480064,0.843743041858024,0.876799252850355,0.907599439637802,0.938399626425159,0.969199813212650,1];
figure('name','Weights as 3D Plot');
% s1, s2, s3, s4 - subplot handles
s1 = subplot(2, 2, 1);
plot3([weights(1, :)' weightsMV(1, :)'], [weights(2, :)' weightsMV(2, :)'], [weights(3, :)', weightsMV(3, :)']);
grid on;
xlabel(ticker(1));
ylabel(ticker(2));
zlabel(ticker(3));
s2 = subplot(2, 2, 2);
plot([weights(2, :)' weightsMV(2, :)'], [weights(3, :)' weightsMV(3, :)'])
xlabel(ticker(2));
ylabel(ticker(3));
grid on
s3 = subplot(2, 2, 3);
plot([weights(1, :)' weightsMV(1, :)'], [weights(3, :)' weightsMV(3, :)'])
xlabel(ticker(1));
ylabel(ticker(3));
grid on
s4 = subplot(2, 2, 4);
% get axes handle, we will need this for legend
ax4 = plot([weights(1, :)' weightsMV(1, :)'], [weights(2, :)' weightsMV(2, :)']);
xlabel(ticker(1));
ylabel(ticker(2));
title('Top');
grid on
hL = gridLegend( ax4, 2, {'TS1', 'TS2'} ,'location','southoutside', 'Orientation','Horizontal');
% 4th subplot needs correction of size and position, due to effects of gridLegend
s3Pos = get(s3,'position');
s4Pos = get(s4,'position');
s4Pos(2:4) = s3Pos(2:4);
set(s4, 'position', s4Pos);
% manipulate the size and position of legend
newPosition = [0.35 0.0 0.3 0.05];
newUnits = 'normalized';
set(hL,'Position', newPosition,'Units', newUnits);
关于legend - MATLAB : subplot with sublegend,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22490033/
我正在为 ggpubr 中的图例位置而苦苦挣扎。我知道我可以修改图例位置 p.e.通过 ggpar(legend = "bottom")。但是,如何将图例标题放在图例键上方? 在 ggplot2 中,
SMF foo tax foo 我有一个来自网页的 html 源代码,上面给出了其中的一部分。现在我想获取 HREF仅当 tax 时的值?所
我想知道是否可以在页眉中插入图例。这样,图例也可以具有与整个文档相关的层次结构。 我在下面有更多相关的文字,但需要为读者突出显示。在这种情况下,个人信息将同时为 legend 和 h2。 h1 是站点
它们似乎都有效,并且都用于 https://matplotlib.org/users/legend_guide.html 中的示例中,尽管 plt.legend 在那里更常见。什么时候应该使用它们?
我无法更改图中分割图例的颜色。我需要两种不同的颜色作为图例和视觉图中的文本。 er<- ggmap(sq_map2) + geom_point(data = sisquoc, size
不幸的是,这件事有多长,我没有办法解决它,因为我没有 build 它,但基本上我要做的就是确保这些值设置为两个小数点,无论它。如果是 100,我希望它读取 100.00,这似乎是我遇到的问题。本节的代
目前,互联网上还没有使用 dc.js 和 dc.legend() 函数实现具有图例的气泡图的示例。 that.sessions_scatterplot .width(830)
我需要 PieChart 中的垂直图例。现在库仅提供 2 个选项:顶部/右侧。如果使用正确 - 图例在几列中。我需要一列中的图例。 我发现了一个 hack - 正确的变换值并将图例放在一列中。 v
将多个黄砖图表放入子图排列时遇到问题。标题和图例仅显示最后一个图表。我尝试了多种编写代码的方法,但无法让所有方法都显示图例和标题。我敢肯定,上类很简单。 这是一段代码: f, ((ax1, ax2),
下面的树状图有两个级别。我想显示顶级节点(节点 A 和节点 B)的图例。对于我使用过的其他类型的图表,图例可以自动生成,也可以明确定义。使用树状图,看起来一个不是自动生成的,如果我明确定义一个,它永远
我们已经使用 jqPlot 实现了 donut chart 。 我们如何将图例添加到 donut chart 的中心? 在此先感谢您的帮助。 最佳答案 根据 jqPlot 文档的建议:jqplot d
我想去掉图例中名称和百分比之间的空格。在图片中,我用黄色突出显示了空间。 例如,我希望第一个图例项是“立陶宛 (30.5%)”。 “立陶宛”和“30.5%”之间的额外空格破坏了我的用户界面。 我的图例
我正在尝试将 AmChart 图表图例合并为一行,但运气不佳。图例是分开的(一个代表一行)。 文档 http://docs.amcharts.com/3/javascriptcharts/AmLege
有人知道是否可以在 Grafana 中定义自定义图例值吗? 来自documentation ,有一些可能的功能: Legend Values Additional values can be show
我需要一个从字典生成数据的代码的图例。我不知道字典中有多少键有没有办法对此进行“动态”图例? import matplotlib.pyplot as plt for host in d.keys():
我有一个 fieldset 工作 - 这是代码: Signed In Users (2
当我将以下样式应用于图例标签时 display: inline; width: 300px; 我看到图例标签的宽度为 300px 它仍然接受宽度。 Here是一个演示。这个元素有什么特别之处吗,因为我
这个问题在这里已经有了答案: Matplotlib: figlegend only printing first letter (2 个回答) pyplot legend label being tr
我有这个代码: List legends = new ArrayList<>(lineChart.lookupAll("Label.chart-legend-item")); Legend legen
我的数据是这样的: service,rating_1,rating_2,rating_3,rating_4,rating_5 renew_patent,0,0,1,2,11 apply_benefit
我是一名优秀的程序员,十分优秀!