Power BI 中的散点图、气泡图和点图Scatter charts, bubble charts, and dot plot charts in Power BI

备注

可以在 Power BI Desktop 和 Power BI 服务中创建并查看这些视觉对象。These visuals can be created and viewed in both Power BI Desktop and the Power BI service. 本文中的步骤和图示来自 Power BI Desktop。The steps and illustrations in this article are from Power BI Desktop.

散点图始终有两个数值轴可以显示:一组沿水平轴的数值数据,另一组沿垂直轴的数值数据。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. Power BI 可以跨水平轴均匀或不均匀地分布这些数据点。Power BI may distribute these data points evenly or unevenly across the horizontal axis. 具体视散点图表示的数据而定。It depends on the data the chart represents.

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

备注

此视频使用较旧版本的 Power BI Desktop。This video uses an older version of Power BI Desktop.

可以设置数据点数量,最多 10,000 个。You can set the number of data points, up to a maximum of 10,000.

何时使用散点图、气泡图或点阵图When to use a scatter chart, bubble chart, or a dot plot chart

散点图和气泡图Scatter and bubble charts

散点图展示了两个数值之间的关系。A scatter chart shows the relationship between two numerical values. 气泡图将数据点替换为气泡,用气泡大小 表示附加的第三个数据维度。A bubble chart replaces data points with bubbles, with the bubble size representing an additional third data dimension.

示例气泡图的屏幕截图。

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

  • 若要显示两个数值之间的关系。To show relationships between two numerical values.

  • 若要将两组数字绘制成一个 x 和 y 坐标系列。To plot two groups of numbers as one series of x and y coordinates.

  • 若要更改水平轴的比例尺,但不是要使用折线图。To use 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 sScatter chart, the better the comparisons that you can make.

除具有上述用途的散点图外,还有气泡图,它是以下情况下的理想之选:In addition to what Scatter charts can do for you, bubble charts are a great choice:

  • 如果数据有三个数据系列,每个系列分别包含一组值。If your data has three data series that each contains a set of values.

  • 若要展示财务数据。To present financial data. 不同的气泡大小对增强特定值的视觉效果很有成效。Different bubble sizes are useful to visually emphasize specific values.

  • 若要使用象限。To use with quadrants.

点阵图Dot plot charts

点阵图类似于气泡图和散点图,不同之处在于其用于沿 X 轴绘制分类数据。A dot plot chart is similar to a bubble chart and scatter chart, but is instead used to plot categorical data along the X-Axis.

点阵图的屏幕截图。

若要沿 X 轴添加分类数据,点阵图是理想之选。They're a great choice if you want to include categorical data along the X-Axis.

先决条件Prerequisites

本教程使用零售分析示例 PBIX 文件This tutorial uses the Retail Analysis sample PBIX file.

  1. 在菜单栏的左上方,选择“文件” > “打开” From the upper left section of the menubar, select File > Open

  2. 查找零售分析示例 PBIX 文件的副本Find your copy of the Retail Analysis sample PBIX file

  3. 在报表视图中打开零售分析示例 PBIX 文件 报表视图屏幕截图图标Open the Retail Analysis sample PBIX file in report view Screenshot of the report view icon..

  4. 选择Select 黄色选项卡的屏幕截图。 ,以添加新报表页。to add a new page.

创建散点图Create a scatter chart

  1. 从空白报表页入手,在“字段”窗格中选择以下字段 :Start on a blank report page and from the Fields pane, select these fields:

    • “销售额” > “每平方英尺的销售额” Sales > Sales Per Sq Ft

    • “销售额” > “总销售差额 %” Sales > Total Sales Variance %

    • “地区” > “地区” District > District

    簇状柱形图、“可视化效果”窗格和突出显示选定字段的“字段”窗格屏幕截图。

  2. 在“可视化效果” 窗格中,选择 “散点图”图标的屏幕截图。In the Visualization pane, select Screenshot of the scatter chart icon. 以将簇状柱形图转换为散点图。to convert the cluster column chart to a scatter chart.

    簇状柱形图转换为散点图的屏幕截图。

  3. 将“地区” 从“详细信息” 拖动到 “图例”。Drag District from Details to Legend.

    此时,Power BI 显示散点图,它沿 Y 轴绘制“总销售额差异(%)” ,并沿 X 轴绘制“销售额/平方英尺” 。Power BI displays 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 well. 数据点扩大到与销售值成正比的量。The data points expand to volumes proportionate with the sales value.

    通过将“销售额”中的“值”添加到“大小”井,将散点图转换为气泡图的屏幕截图。

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

    工具提示显示

  3. 若要设置气泡图中显示的数据点数,请在“可视化效果” 窗格的“格式” 部分中,展开“常规” ,并调整“数据量” 。To set the number of data points to show in your bubble chart, in the Format section of the Visualizations pane, expand General, and adjust the Data Volume.

    突出显示“格式”图标、“常规”下拉列表和“数据量”选项的“可视化效果”窗格屏幕截图。

    可以将最大数据量设置为 10,000 及以下的任意数量。You can set the max data volume to any number up to 10,000. 随着数据的增加,建议先进行测试,以确保性能良好。As you get into the higher numbers, we suggest testing first to ensure good performance.

    备注

    数据点越多可能意味着加载时间越长。More data points can mean a longer loading time. 如果确实选择发布有比例尺上限的报表,请务必也要跨 Web 和移动设备测试报表。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. 建议确认图表的性能是否符合用户预期。You want to confirm that the performance of the chart matches your users' expectations.

  4. 可以设置可视化颜色、标签、标题、背景等等You can format the visualization colors, labels, titles, background, and more.

    若要提高可访问性,请考虑将标记形状添加到每个行。To improve accessibility, consider adding marker shapes to each line. 若要选择标记形状,请展开“形状” ,并依次选择“标记形状” 和形状。To select the marker shape, expand Shapes, select Marker shape, and select a shape.

    突出显示“标记形状”选项的“形状”下拉列表屏幕截图。

    可以将标记形状更改为钻石形、三角形或方形。You can change the marker shape to a diamond, triangle, or square. 对每行使用不同的标记形状可便于报表使用者更轻松地区分各行(或区域)。Using a different marker shape for each line makes it easier for report consumers to differentiate lines (or areas) from each other.

创建点阵图Create a dot plot chart

若要创建点阵图,请将数字“X 轴” 字段替换为分类字段。To create a dot plot chart, replace the numerical X-Axis field with a categorical field.

在“X 轴” 窗格中,删除“销售额/平方英尺” ,并改为依次选择“区域” > “区域经理” 。From the X-Axis pane, remove Sales per sq ft and replace it with District > District Manager.

新点阵图的屏幕截图。

注意事项和疑难解答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 well to tell Power BI how to group the values. 每个要绘制的点必须具有唯一的字段。The field must be unique for each point you want to plot. 简单的行号或 ID 字段即可。A simple row number or ID field will do.

将“RowNum”添加到“详细信息”井的散点图的屏幕截图。

如果数据中没有这些字段,可以创建一个字段,将 X 值和 Y 值全部连接到每个点对应的唯一字段中: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:

将“TempTime”添加到“详细信息”井的散点图的屏幕截图。

要创建新字段,请使用 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 your visualization's Details well.

后续步骤Next steps

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