【发布时间】:2011-10-27 19:14:34
【问题描述】:
我正在为 Mathematica 中的各种绘图/图表绘制创建应用程序。最终它将有一个 GUI,但第一步是让代码正确,并且足够简单,以便 GUI 管理。我很难将图例设置为周围没有框架。
这是一个最小示例(BarChart 上的一些选项已经使用 SetOptions 进行了自定义。
mydata = {4.5644, 5.546, 6.8674, 2.7688, 1.742, 5.3952, 4.3392, 4.5016, \
3.7748, 1.838, 2.24, 0.693, 2.818, 4.9, 3.939, 3.459, 3.755, 4.475, \
3.857, 3.215, 2.206, 2.206, 2.117, 3.403, 3.277, 3.761, 4.276, 2.559, \
3.486, 4.778, 2.281, 2.865, 3.629, 4.916, 4.572, 5.244, 5.395, 2.865, \
-0.524, 5.01, 4.401, 4.513, 4.54}
BarChart[mydata,
ChartStyle -> {Join[
Table[RGBColor[0.5, 0.5, 0.95], {Length[mydata] - 3}], {Magenta,
Magenta, Magenta}]}, PlotRange -> {-2, 8},
ChartLegends -> {Join[
Table[None, {Length[mydata] - 3}], {Placed[
Style["Forecasts", FontFamily -> "Arial", FontSize -> 18],
Bottom]}]}, BarSpacing -> 0.4,
LegendAppearance -> Directive[Background -> Red,
Frame -> None, ImageSize -> 15]]
这是我得到的:
尽我所能,我无法摆脱传说中的边界。你可以看到LegendAppearance 什么也没做——我也尝试了其他一些方法。
我不愿意手动编写小矩形,因为在最终的 GUI 中很难做到这一点。 ChartLabels 也不起作用,因为它已经被用于实际版本图表中的日期标签。
有人有什么建议吗?
【问题讨论】:
标签: charts wolfram-mathematica bar-chart