Power BI 中的散点图和气泡图(教程)Scatter charts and bubble charts in Power BI (Tutorial)

散点图始终具有两个数值轴以显示水平轴上的一组数值数据和垂直轴上的另一组数值数据。A scatter chart always has two value axes to show one set of numerical data along a horizontal axis and another set of numerical values along a vertical axis. 图表在 x 和 y 数值的交叉处显示点,将这些值单独合并到各个数据点。The chart displays points at the intersection of an x and y numerical value, combining these values into single data points. 根据数据,这些数据点可能均衡或不均衡地分布在水平轴上。These data points may be distributed evenly or unevenly across the horizontal axis, depending on the data.

气泡图将数据点替换为气泡,用气泡大小表示数据的其他维度。A bubble chart replaces the data points with bubbles, with the bubble size representing an additional dimension of the data.

可以设置数据点数量You can set the number of data points

何时使用散点图或气泡图When to use a scatter chart or bubble chart

以下情况下,散点图是一个不错的选择:Scatter charts are a great choice:

  • 要显示 2(散点)或 3(气泡)值之间的关系。to show relationships between 2 (scatter) or 3 (bubble) numerical values.
  • 要将两组数字绘制为一个数据系列的 xy 坐标。to plot two groups of numbers as one series of xy coordinates.
  • 要更改水平轴刻度,但不是绘制成折线图。instead of a line chart when you want to change the scale of the horizontal axis
  • 要将水平轴转换为对数刻度。to turn the horizontal axis into a logarithmic scale.
  • 要显示包含成对或分组的值的工作表数据。to display worksheet data that includes pairs or grouped sets of values. 在散点图中,你可以调整轴的自由刻度来显示分组值的详细信息。In a scatter chart, you can adjust the independent scales of the axes to reveal more information about the grouped values.
  • 要显示大组数据中的模式,例如要显示线性或非线性趋势、群集和离群值。to show patterns in large sets of data, for example by showing linear or non-linear trends, clusters, and outliers.
  • 要在不考虑时间的情况下,比较大量数据点。to compare large numbers of data points without regard to time. 散点图中包含的数据越多,比较的效果就越好。The more data that you include in a scatter chart, the better the comparisons that you can make.

在以下情况下,气泡图是一个不错的选择:Bubble charts are a great choice:

  • 如果数据具有 3 个分别含有一组值的数据系列。if your data has 3 data series that each contain a set of values.
  • 要展示财务数据。to present financial data. 不同的气泡大小对增强特定值的视觉效果很有成效。Different bubble sizes are useful to visually emphasize specific values.
  • 要使用象限。to use with quadrants.

创建散点图Create a scatter chart

观看此视频了解 Will 如何创建散点图,然后遵循以下步骤自行创建一个。Watch this video to see Will create a scatter chart and then follow the steps below to create one yourself.

以下说明使用零售分析示例。These instructions use the Retail Analysis Sample. 若要继续学习,请下载适用于 Power BI 服务 (app.powerbi.com) 或 Power BI Desktop 的示例。To follow along, download the sample for Power BI service (app.powerbi.com) or Power BI Desktop.

  1. 空白报表页开始,选择“销售额”>“每平方英尺销售额”和“销售” > “总销售额差异百分比”字段。Start on a blank report page and select the Sales > Sales Per Sq Ft and Sales > Total Sales Variance % fields. 如果使用的是 Power BI 服务,请确保在 “编辑视图” 中打开报表。If you're using Power BI service, make sure you open the report in Editing View.

  2. 从字段窗格中,选择“地区>地区”。From the Fields pane, select District > District.

  3. 转换为散点图。Convert to a scatter chart. 在可视化组件窗格中,选择散点图图标In the Visualization pane, select the Scatter chart icon. ..
  4. 将“地区”从“详细信息”拖动到“图例”。Drag District from Details to Legend.

现在,我们绘制了一个散点图,其中销售总额方差 % 沿 Y 轴绘制,每平方英尺的销售额沿 X 轴绘制。We now have a scatter chart that plots Total Sales Variance % along the Y axis, and plots Sales Per Square Feet along the X axis. 数据点的颜色表示地区。The data point colors represent districts. 现在让我们添加第三个维度。Now let's add a third dimension.

创建气泡图Create a bubble chart

  1. 从字段窗格中,依次将“销售额” > “今年销售额” > “值”拖动到“大小”区域。From the Fields pane, drag Sales > This Year Sales > Value to the Size area.

  2. 将鼠标悬停在一个气泡上。Hover over a bubble. 该气泡的大小反映了“今年销售额”的值。The size of the bubble reflects the value of This Year Sales.

  3. 根据需要,可以设置可视化颜色、标签、标题、背景等等Optionally, format the visualization colors, labels, titles, background, and more.

    还可以将标记形状更改为菱形、三角形或方形:You can also change the marker shape to diamond, triangle, or square:


  4. (可选)若要设置气泡图中显示的数据点数量,请在“可视化效果”窗格的“格式”部分中,展开“常规”卡片,并调整“数据量”。Optionally, to set the number of data points to show in your bubble chart, in the Format section of the Visualizations pane, expand the General card and adjust the Data Volume. 默认值为 3500。The default is 3500.



    由于数据点越多可能意味着加载时间越长,因此如果选择发布已达到数据点上限的报表,请务必跨网站平台和移动平台测试报表,以确保报表性能符合用户预期。Because more data points can mean a longer loading time, if you do choose to publish reports with limits at the higher end of the scale, make sure to test out your reports across the web and mobile as well to ensure performance matches your users’ expectations.

  5. (可选)若要选择标记形状,请展开“形状”卡片,再选择标记形状。Optionally, to select the marker shape, expand the Shapes card, then select a marker shape.


注意事项和疑难解答Considerations and Troubleshooting

散点图只有一个数据点Your scatter chart has only one data point

你的散点图是否只有一个聚合 X 和 Y 轴上的所有值的数据点?Does your scatter chart have only one data point that aggregates all the values on the X and Y axes? 或者,也许聚合了水平线或垂直线上的所有值?Or maybe it aggregates all the values along a single horizontal or vertical line?

将字段添加到“详细信息”区域以告知 Power BI 应如何对值进行分组。Add a field to the Details area to tell Power BI how to group the values. 每个要绘制的点必须具有唯一的字段。The field must be unique for each point you want to plot.
例如可以是简单的行号或 ID 字段:Like a simple row number or ID field:

或者,如果数据中没有这些内容,则可以创建一个字段,将 X 和 Y 值全部连接到每个点对应的唯一字段中:Or if you don’t have that in your data, create a field that concatenates your X and Y values together into something unique per point:

要创建新字段,请使用 Power BI Desktop 查询编辑器将索引列添加到数据集To create a new field, use the Power BI Desktop Query Editor to add an Index Column to your dataset. 然后将该列添加到你的可视化效果的详细信息区域。Then add this column to the Details area of your visualization.

后续步骤Next steps

Power BI 中的可视化效果类型Visualization types in Power BI

试用一下 - 完全免费!Try it out -- it's free!

更多问题?More questions? 尝试参与 Power BI 社区Try the Power BI Community