可以删除条形图图例上的边框吗? [英] Can the frame border on a BarChart Legend be removed?

查看:17
本文介绍了可以删除条形图图例上的边框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Mathematica 中的各种绘图/图表绘制创建一个应用程序.最终它会有一个 GUI,但第一步是让代码正确,并且足够简单以供 GUI 管理.我很难将图例设置为没有边框.

I am creating an application for various kinds of plot/chart drawing in Mathematica. Ultimately it will have a GUI, but the first step is to get the code right, and simple enough for a GUI to manage. I am having difficulty setting legends to have no frame around them.

这是一个最小的例子(BarChart 上的一些选项已经使用 SetOptions 自定义.

Here is a minimal example (with some options on BarChart already customised using 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 什么也没做 - 我也尝试了其他一些方法.

Try as I might, I can't get rid of that border round the legend. You can see that LegendAppearance does nothing - I've tried a few other approaches to it, too.

我不愿手动编写小矩形,因为在最终的 GUI 中很难做到正确.ChartLabels 也不起作用,因为它已经被用于图表的真实版本中的日期标签.

I'm reticent to code up little rectangles by hand, because that will be very difficult to get right in the eventual GUI. ChartLabels won't work either, because that is already being used for date labels in the real version of the graph.

大家有什么建议吗?

推荐答案

你可以通过设置:

SetOptions[Legending`GridLegend, Legending`LegendContainer -> Identity]

要恢复默认行为,请设置:

To restore the default behavior, set:

SetOptions[Legending`GridLegend, Legending`LegendContainer -> Automatic]

这篇关于可以删除条形图图例上的边框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆