Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wolfram mathematica 如何阻止条形图在Mathematica中隐藏数据值0的标签?_Wolfram Mathematica_Bar Chart_Mathematica 8 - Fatal编程技术网

Wolfram mathematica 如何阻止条形图在Mathematica中隐藏数据值0的标签?

Wolfram mathematica 如何阻止条形图在Mathematica中隐藏数据值0的标签?,wolfram-mathematica,bar-chart,mathematica-8,Wolfram Mathematica,Bar Chart,Mathematica 8,我使用此选项创建条形图: BarChart[ Reverse@data, BarOrigin -> Left, ChartLabels -> Placed[{Reverse@labels, Reverse@data}, {Before, After}], ChartElementFunction -> "FadingRectangle" ] 使用data={7,10,0,6,0,3,5} 问题是一些数据值为0,BarChart甚至不会为它们添加标签。相反,它

我使用此选项创建条形图:

BarChart[
 Reverse@data,
 BarOrigin -> Left,
 ChartLabels -> 
  Placed[{Reverse@labels, Reverse@data}, {Before, After}],
 ChartElementFunction -> "FadingRectangle"
 ]
使用
data={7,10,0,6,0,3,5}

问题是一些数据值为0,
BarChart
甚至不会为它们添加标签。相反,它留下了一个开放的空间。如何使其在值为0的情况下仍添加标签


这就是Mathematica 8。

最简单的方法是使用类似于
data/的黑客。{(0 | 0.0)->0.00001}

我认为这应该在不需要黑客的情况下工作,所以你也应该向support@wolfram.com.

怎么样

data = {7, 10, 0, 6, 0, 3, 5}

labels = ("label " ~~ ToString[#]) & /@ data

BarChart[Reverse@data, BarOrigin -> Left,
ChartLabels -> Placed[{Reverse@labels, Reverse@data}, {Axis, After}],
ChartElementFunction -> "FadingRectangle"]
似乎“之前”不起作用,“轴”起作用


您的代码在Windows 7上的Mathematica 7中给出

data = {7, 10, 0, 6, 0, 3, 5};

labels = Row[{"label",#}]& /@ data;

BarChart[
  Reverse@data,
  BarOrigin -> Left,
  ChartLabels ->
   Placed[{Reverse@labels, Reverse@data}, {Before, After}],
  ChartElementFunction -> "FadingRectangle"
]

可能相关:这是一个粗略的解决方法,但如果没有更好的解决方法,您可以执行
条形图[Reverse[data/.x/;x==0->10^-5],…
(即在绘图之前用小数字替换零)。我使用了模式
x|x==0
来匹配0和0.0…我想0 | 0.0也会很好。我意识到我在编辑样本数据集并绘制到问题中时犯了一个错误:数据集可能是实数,所以
0 | 0.0->0.00001
或类似的东西会更好。@Szabolcs很好的一点。我添加了你的应用程序roach(在简要考虑了
PossibleZeroQ
…)我想我应该指定我使用的是Mathematica 8。这看起来是最干净的解决方案,即使你仍然松开了第二个标签。