处理 Mathematica 图表中的刻度

发布于 2024-12-01 09:23:15 字数 1130 浏览 2 评论 0原文

请考虑:

dalist = {{379, 219, 228, 401}, {387, 239, 230, 393},      
          {403, 238, 217, 429}, {377, 233, 225, 432}}

BarChart[dalist, 
         Frame -> True, 
         FrameTicks -> {{None, None}, {None, None}}]

在此处输入图像描述

我无法弄清楚处理蜱虫本身和范围的方法(数字)。我想看到范围,但不想看到如下所示的刻度:

在此处输入图像描述

编辑:

后,似乎我又创造了新的问题。 总结一下,我想看到: TicksLabel 但不是 Ticks(已解决) FrameLabel 但不是 Frame。

下面就来说明一下这个问题。 FrameStyle 控制框架标签。 因此,将 opacity[0] 应用于 FrameStyle 来隐藏框架会隐藏框架标签。

BarChart[Range[10],
 ChartStyle -> Black,
 PlotRangePadding -> 0,
 Frame -> {{True, False}, {True, False}},
 FrameLabel -> {{"Why?", None}, {"Because !", None}},
 FrameTicksStyle -> Opacity[1],
 FrameStyle -> Opacity[0],

 PlotLabel -> Style["Bonjour", Bold, 16, Opacity[1]],
 LabelStyle -> Directive[Black, Bold, 12, Opacity[1]],
 ImageSize -> 400]

在此处输入图像描述

Please consider :

dalist = {{379, 219, 228, 401}, {387, 239, 230, 393},      
          {403, 238, 217, 429}, {377, 233, 225, 432}}

BarChart[dalist, 
         Frame -> True, 
         FrameTicks -> {{None, None}, {None, None}}]

enter image description here

I can`t figure out the way to deal with the ticks themselves and the range (the numbers). I would like to see the Range but not the ticks like the below :

enter image description here

EDIT :

Having solved some problem, it seems I created new ones.
To Summarize, I would like to see :
TicksLabel but not the Ticks (solved)
FrameLabel but not the Frame.

The Below shall illustrate the problem. FrameStyle control the Frame Label.
So applying opacity[0] to FrameStyle to hide the frame hides the frame Label.

BarChart[Range[10],
 ChartStyle -> Black,
 PlotRangePadding -> 0,
 Frame -> {{True, False}, {True, False}},
 FrameLabel -> {{"Why?", None}, {"Because !", None}},
 FrameTicksStyle -> Opacity[1],
 FrameStyle -> Opacity[0],

 PlotLabel -> Style["Bonjour", Bold, 16, Opacity[1]],
 LabelStyle -> Directive[Black, Bold, 12, Opacity[1]],
 ImageSize -> 400]

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

皓月长歌 2024-12-08 09:23:15

Ticks 和 FrameTicks 有可选的更复杂的语法,其中每个刻度可以指定为 {x,label,{length_inside,length_outside}}

因此,要获得不带刻度的刻度标签,请将第二对数字指定为两个零。
要复制示例中的刻度,您可以使用

FrameTicks->{{Table[{j,j,{0,0}},{j,0,300000,50000}],None},
 {Table[{k,k,{0,0}},{k,2010,2015}],None}}

对于条形图,条形图位于 1、2、3...x 位置,因此这需要是:

FrameTicks->{{Table[{j,j,{0,0}},{j,0,300000,50000}],None},
 {Table[{k,k+2009,{0,0}},{k,1,6}],None}}

按照注释中的要求,如果您想要数字但没有刻度并且没有框架,添加:

FrameTicksStyle -> Opacity[1], FrameStyle -> Opacity[0]

编辑并在任何框架标签上使用样式

最终结果:

data = RandomReal[{0, 300000}, {10}]
BarChart[data, 
 FrameTicks -> {{Table[{j, j, {0, 0}}, {j, 0, 300000, 50000}], 
 None}, {Table[{k, k + 2009, {0, 0}}, {k, 1, 10}], None}}, 
 Frame -> True, FrameTicksStyle -> Opacity[1], FrameStyle -> Opacity[0],
 FrameLabel -> {{Style["Why?", Opacity[1]],  None}, 
   {Style["Axes", Opacity[1]], None}}]

在此处输入图像描述

我对 这个问题可能帮助照亮。

Ticks and FrameTicks have optional more complex syntax, where each tick can be specified as {x,label,{length_inside,length_outside}}

So to have ticks labels without ticks, specify the second pair of numbers as two zeros.
To replicate the ticks in your example, you would use

FrameTicks->{{Table[{j,j,{0,0}},{j,0,300000,50000}],None},
 {Table[{k,k,{0,0}},{k,2010,2015}],None}}

For BarCharts, the bars are at 1, 2, 3... x-positions, so this needs to be:

FrameTicks->{{Table[{j,j,{0,0}},{j,0,300000,50000}],None},
 {Table[{k,k+2009,{0,0}},{k,1,6}],None}}

As requested in comments, if you want numbers but no ticks and no frame, add:

FrameTicksStyle -> Opacity[1], FrameStyle -> Opacity[0]

EDIT And use Style on any frame labels.

End result:

data = RandomReal[{0, 300000}, {10}]
BarChart[data, 
 FrameTicks -> {{Table[{j, j, {0, 0}}, {j, 0, 300000, 50000}], 
 None}, {Table[{k, k + 2009, {0, 0}}, {k, 1, 10}], None}}, 
 Frame -> True, FrameTicksStyle -> Opacity[1], FrameStyle -> Opacity[0],
 FrameLabel -> {{Style["Why?", Opacity[1]],  None}, 
   {Style["Axes", Opacity[1]], None}}]

enter image description here

My answer to this question might help illuminate.

維他命╮ 2024-12-08 09:23:15

也许您正在寻找 ChartLabels

BarChart[dalist, ChartLabels -> Placed[Flatten@dalist, Below], 
                 FrameTicks -> {{Automatic, None}, {None, None}},
                 Frame -> True, 
                 Ticks -> None]

在此处输入图像描述

Perhaps you are looking for ChartLabels:

BarChart[dalist, ChartLabels -> Placed[Flatten@dalist, Below], 
                 FrameTicks -> {{Automatic, None}, {None, None}},
                 Frame -> True, 
                 Ticks -> None]

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文