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

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

问题描述

我在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]]

这里是我得到的:

And here is what I get:

尽量尝试,我无法摆脱边界围绕传说。你可以看到 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]

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

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