vba 在Excel散点图中使用文本作为水平标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44484833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 12:43:27  来源:igfitidea点击:

Use text as horizontal labels in Excel scatter plot

excelexcel-vbaplotexcel-2010excel-2007vba

提问by Jamgreen

I am trying to make a scatter plot in Excel with text as horizontal axis labels.

我想用文本作为水平轴标签在 Excel 中制作散点图。

I have the data

我有数据

enter image description here

在此处输入图片说明

and I want a chart like this

我想要这样的图表

enter image description here

在此处输入图片说明

The way I produced this chart was to have a scatter plot with numeric X values and numeric Y values, so instead of Poland I have X=1 and Y=10, Y=11, Y=12, and Y=9. For Germany I chose X=2 and Y=8 and Y=7. I just added some text boxes with the names to hide the numeric X values.

我制作这个图表的方法是有一个散点图,其中包含数字 X 值和数字 Y 值,所以我用 X=1 和 Y=10、Y=11、Y=12 和 Y=9 代替波兰。对于德国,我选择了 X=2 和 Y=8 和 Y=7。我只是添加了一些带有名称的文本框来隐藏数字 X 值。

enter image description here

在此处输入图片说明

But I want this to be dynamic, so I tried to set the X value labels here:

但我希望这是动态的,所以我尝试在这里设置 X 值标签:

enter image description here

在此处输入图片说明

but I am not able to change the horizontal values.

但我无法更改水平值。

How can I solve this problem?

我怎么解决这个问题?

回答by teylyn

You need a helper series. Consider the following screenshot:

你需要一个帮手系列。考虑以下屏幕截图:

enter image description here

在此处输入图片说明

The blue dots are plotted from the data in the table on the left. The orange dots are plotted from the helper table. Each orange dot then has a data label assigned. Edit each data label individually, type a =character and click the cell that has the corresponding text.

蓝点是根据左侧表格中的数据绘制的。橙色点是从帮助表中绘制的。然后每个橙色点都分配了一个数据标签。单独编辑每个数据标签,键入一个=字符并单击具有相应文本的单元格。

This process can be automated with the free XY Chart Labeler add-in. Excel 2013 and newer has the option to include "Value from cells" in the data label dialog.

这个过程可以通过免费的 XY Chart Labeler 插件实现自动化。Excel 2013 及更高版本可以选择在数据标签对话框中包含“单元格中的值”。

Format the data labels to your preferences and hide the original x axis labels.

根据您的偏好设置数据标签的格式并隐藏原始 x 轴标签。