使用 Python 在簡報中管理圖表資料標籤
介紹
資料標籤顯示圖表系列和單個資料點的資訊,協助讀者辨識值並了解圖表。本文說明如何格式化值、顯示百分比、讀取標籤文字、在軸最大值之外控制標籤、調整類別軸標籤間距,以及定位圓餅圖標籤。
計算可見資料標籤
使用getCountOfVisibleDataLabels來檢查在發佈簡報之前,有多少資料標籤已啟用顯示。與返回集合中標籤總數的getCount不同,它會考慮系列的預設值和個別標籤設定。
此示例建立一個包含一個系列和三個資料點的直條圖。它透過getLabels存取系列的標籤集合,並在設定變更時列印可見計數:0, 3, 2, 3。總計數仍為3。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300)
chart.getChartData().getSeries().clear()
chart.getChartData().getCategories().clear()
workbook = chart.getChartData().getChartDataWorkbook()
series_cell = workbook.getCell(0, 0, 1, "Values")
series = chart.getChartData().getSeries().add(series_cell, chart.getType())
for i in range(3):
category_cell = workbook.getCell(0, i + 1, 0, f"Category {i + 1}")
chart.getChartData().getCategories().add(category_cell)
value_cell = workbook.getCell(0, i + 1, 1, jpype.JDouble((i + 1) * 10))
series.getDataPoints().addDataPointForBarSeries(value_cell)
labels = series.getLabels()
print(f"Total: {labels.getCount()}; visible: {labels.getCountOfVisibleDataLabels()}") # 總計: 3;可見: 0
labels.getDefaultDataLabelFormat().setShowValue(True)
print(f"Visible: {labels.getCountOfVisibleDataLabels()}") # 可見: 3
labels.get_Item(1).getDataLabelFormat().setShowValue(False)
print(f"Visible: {labels.getCountOfVisibleDataLabels()}") # 可見: 2
labels.get_Item(1).getDataLabelFormat().setShowLegendKey(True)
print(f"Visible: {labels.getCountOfVisibleDataLabels()}") # 可見: 3
finally:
presentation.dispose()
系列的getDefaultDataLabelFormat提供預設設定。將True傳遞給setShowValue會顯示所有三個標籤的值。透過某個標籤的getDataLabelFormat傳遞False會覆寫該標籤的設定。將True傳遞給setShowLegendKey會使該標籤再次被計算為可見,即使其值仍被隱藏。
可見計數反映可見性設定。它不會衡量標籤是否重疊、被裁切,或在渲染的圖表中是否可讀。
設定圖表資料標籤的數值精度
使用setNumberFormatOfValues來格式化系列值。此示例建立一個具有預設資料的折線圖,顯示其資料表,並為第一個系列啟用值標籤。格式#,##0.00會顯示千位分隔符和兩位小數,且不會更改底層值。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, Presentation, SaveFormat
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.Line, 50, 50, 450, 300)
chart.setDataTable(True)
series = chart.getChartData().getSeries().get_Item(0)
series.setNumberFormatOfValues("#,##0.00")
series.getLabels().getDefaultDataLabelFormat().setShowValue(True)
presentation.save("PrecisionOfDatalabels_out.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
若要格式化圖表嵌入式工作簿中的數值儲存格,請參閱設定工作簿儲存格的自訂數字格式。該示例亦展示了值標籤遵循其來源儲存格格式,同時保留儲存的數值。
將百分比顯示為標籤
對於堆疊直條圖,將每個值計算為其類別總和的百分比,並將文字指派給由getTextFrameForOverriding返回的文字框。此示例使用預設圖表資料,並以 8 點字型顯示兩位小數的百分比。總和為零的類別會被略過,以避免除以零。若圖表資料變更,請重新計算自訂標籤文字。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, Portion, Presentation, SaveFormat
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.StackedColumn, 20, 20, 400, 400)
chart_series = chart.getChartData().getSeries()
category_totals = [0.0] * chart.getChartData().getCategories().size()
for category_index in range(len(category_totals)):
for series_index in range(chart_series.size()):
data_point = chart_series.get_Item(series_index).getDataPoints().get_Item(category_index)
category_totals[category_index] += float(data_point.getValue().getData())
for series_index in range(chart_series.size()):
series = chart_series.get_Item(series_index)
series.getLabels().getDefaultDataLabelFormat().setShowLegendKey(False)
for point_index in range(series.getDataPoints().size()):
data_point = series.getDataPoints().get_Item(point_index)
label = data_point.getLabel()
if category_totals[point_index] == 0:
print(f"Cannot calculate a percentage for category {point_index}: the total is zero.")
continue
point_percentage = float(data_point.getValue().getData()) / category_totals[point_index] * 100
portion = Portion()
portion.setText(f"{point_percentage:.2f} %")
portion.getPortionFormat().setFontHeight(8)
label.getTextFrameForOverriding().setText("")
paragraph = label.getTextFrameForOverriding().getParagraphs().get_Item(0)
paragraph.getPortions().add(portion)
label_format = label.getDataLabelFormat()
label_format.setShowValue(True)
label_format.setShowSeriesName(False)
label_format.setShowPercentage(False)
label_format.setShowLegendKey(False)
label_format.setShowCategoryName(False)
label_format.setShowBubbleSize(False)
presentation.save("DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
在圖表資料標籤中設定百分比符號
當值以分數形式儲存時,使用setNumberFormat來顯示百分比。將False傳遞給setNumberFormatLinkedToSource可使標籤格式獨立於來源儲存格。
此示例建立一個 100% 堆疊直條圖,包含紅色和藍色系列,跨四個類別。每對值總和為 1。標籤格式0.0%會將 0.30 顯示為 30.0%,而垂直軸使用兩位小數。兩個系列皆使用白色、10 點字型的標籤文字。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, FillType, Presentation, SaveFormat
Color = jpype.JClass("java.awt.Color")
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.PercentsStackedColumn, 20, 20, 500, 400)
chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(False)
chart.getAxes().getVerticalAxis().setNumberFormat("0.00%")
chart.getChartData().getSeries().clear()
chart.getChartData().getCategories().clear()
workbook = chart.getChartData().getChartDataWorkbook()
worksheet_index = 0
for i in range(4):
category_cell = workbook.getCell(worksheet_index, i + 1, 0, f"Category {i + 1}")
chart.getChartData().getCategories().add(category_cell)
series_names = ["Reds", "Blues"]
series_colors = [Color.RED, Color.BLUE]
values = [[0.30, 0.50, 0.80, 0.65], [0.70, 0.50, 0.20, 0.35]]
for i, series_name in enumerate(series_names):
series_cell = workbook.getCell(worksheet_index, 0, i + 1, series_name)
series = chart.getChartData().getSeries().add(series_cell, chart.getType())
for j, value in enumerate(values[i]):
value_cell = workbook.getCell(worksheet_index, j + 1, i + 1, jpype.JDouble(value))
series.getDataPoints().addDataPointForBarSeries(value_cell)
series.getFormat().getFill().setFillType(FillType.Solid)
series.getFormat().getFill().getSolidFillColor().setColor(series_colors[i])
label_format = series.getLabels().getDefaultDataLabelFormat()
label_format.setShowValue(True)
label_format.setNumberFormatLinkedToSource(False)
label_format.setNumberFormat("0.0%")
portion_format = label_format.getTextFormat().getPortionFormat()
portion_format.setFontHeight(10)
portion_format.getFillFormat().setFillType(FillType.Solid)
portion_format.getFillFormat().getSolidFillColor().setColor(Color.WHITE)
presentation.save("SetDataLabelsPercentageSign_out.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
讀取資料標籤的實際文字
使用getActualLabelText來取得資料標籤設定產生的文字。這在為報告擷取標籤、搜尋簡報內容或驗證產生的圖表時很有用。以下範例中,預設的data label format會結合每個類別名稱、系列名稱及值。某個點將其值格式化為百分比,另一個則使用來自getTextFrameForOverriding的自訂文字。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300)
chart.getChartData().getSeries().clear()
chart.getChartData().getCategories().clear()
workbook = chart.getChartData().getChartDataWorkbook()
first_category_cell = workbook.getCell(0, 1, 0, "Q1")
chart.getChartData().getCategories().add(first_category_cell)
second_category_cell = workbook.getCell(0, 2, 0, "Q2")
chart.getChartData().getCategories().add(second_category_cell)
north_series_cell = workbook.getCell(0, 0, 1, "North")
north = chart.getChartData().getSeries().add(north_series_cell, chart.getType())
north_first_value_cell = workbook.getCell(0, 1, 1, jpype.JDouble(0.25))
north.getDataPoints().addDataPointForBarSeries(north_first_value_cell)
north_second_value_cell = workbook.getCell(0, 2, 1, jpype.JDouble(0.75))
north.getDataPoints().addDataPointForBarSeries(north_second_value_cell)
south_series_cell = workbook.getCell(0, 0, 2, "South")
south = chart.getChartData().getSeries().add(south_series_cell, chart.getType())
south_first_value_cell = workbook.getCell(0, 1, 2, jpype.JDouble(0.40))
south.getDataPoints().addDataPointForBarSeries(south_first_value_cell)
south_second_value_cell = workbook.getCell(0, 2, 2, jpype.JDouble(0.60))
south.getDataPoints().addDataPointForBarSeries(south_second_value_cell)
for series in chart.getChartData().getSeries():
label_format = series.getLabels().getDefaultDataLabelFormat()
label_format.setShowCategoryName(True)
label_format.setShowSeriesName(True)
label_format.setShowValue(True)
north.getLabels().get_Item(1).getDataLabelFormat().setNumberFormatLinkedToSource(False)
north.getLabels().get_Item(1).getDataLabelFormat().setNumberFormat("0%")
south.getLabels().get_Item(0).getTextFrameForOverriding().setText("Reviewed")
for series in chart.getChartData().getSeries():
for point in series.getDataPoints():
label = point.getLabel()
if not label.isVisible():
continue
print(f"Value: {point.getValue().getData()}; label: {label.getActualLabelText()}")
finally:
presentation.dispose()
資料點中儲存的數字仍為0.75,即使其標籤顯示75%以及類別和系列名稱。自訂文字會取代產生的標籤文字。getActualLabelText在兩種情況下皆返回最終的標籤字串。如需僅擷取可見標籤,請如上所示單獨檢查isVisible。
在軸最大值之外控制資料標籤
手動限制軸範圍時,某些資料點可能超過其最大值。使用setShowDataLabelsOverMaximum來控制是否顯示它們的資料標籤。此設定會變更標籤的可見性;不會改變軸範圍或底層資料值。
以下範例建立一個 2D 群組直條圖,值為 60 和 120。它將False傳遞給setAutomaticMaxValue 並在垂直軸上使用setMaxValue將最大值設定為 100。第一張投影片允許超出最大值的標籤;該投影片的複本會停用它們。兩張投影片皆儲存為DataLabelsOverMaximum.pptx。
使用setShowValue啟用值標籤。圖表層級的設定不會單獨啟用值顯示,也不會覆寫個別標籤已停用的值顯示。此示例為整個系列啟用值,並使用setPosition將標籤放置於每個直欄的外端。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, LegendDataLabelPosition, Presentation, SaveFormat
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400)
chart.setLegend(False)
chart.getChartData().getSeries().clear()
chart.getChartData().getCategories().clear()
workbook = chart.getChartData().getChartDataWorkbook()
first_category = workbook.getCell(0, 1, 0, "Within range")
second_category = workbook.getCell(0, 2, 0, "Above maximum")
chart.getChartData().getCategories().add(first_category)
chart.getChartData().getCategories().add(second_category)
series_name = workbook.getCell(0, 0, 1, "Values")
series = chart.getChartData().getSeries().add(series_name, chart.getType())
first_value = workbook.getCell(0, 1, 1, jpype.JDouble(60))
second_value = workbook.getCell(0, 2, 1, jpype.JDouble(120))
series.getDataPoints().addDataPointForBarSeries(first_value)
series.getDataPoints().addDataPointForBarSeries(second_value)
series.getLabels().getDefaultDataLabelFormat().setShowValue(True)
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.OutsideEnd)
chart.getAxes().getVerticalAxis().setAutomaticMaxValue(False)
chart.getAxes().getVerticalAxis().setMaxValue(100)
chart.setShowDataLabelsOverMaximum(True)
second_slide = presentation.getSlides().addClone(slide)
second_chart = second_slide.getShapes().get_Item(0)
second_chart.setShowDataLabelsOverMaximum(False)
presentation.save("DataLabelsOverMaximum.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
以下圖片顯示由 Microsoft PowerPoint 呈現的已儲存投影片。使用True時,標籤120在上界可見;使用False時則被隱藏。標籤60仍保持可見,軸最大值仍為100,且第二個資料點在兩種情況下皆為120。
| setShowDataLabelsOverMaximum(True) | setShowDataLabelsOverMaximum(False) |
|---|---|
![]() |
![]() |
Chart Type
此示例使用具有值軸的 2D 直條圖。沒有值軸的圖表,如圓餅圖和環形圖,並沒有此類可限制的軸最大值。設定標籤與軸的距離
使用setLabelOffset來控制類別軸標籤與軸之間的距離。該值為軸標籤最大字型大小的百分比。此示例建立一個群組直條圖,並將水平軸標籤偏移設定為 500。此設定會影響類別軸標籤,而非附加於單一資料點的標籤。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, Presentation, SaveFormat
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300)
chart.getAxes().getHorizontalAxis().setLabelOffset(500)
presentation.save("SetCategoryAxisLabelDistance_out.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
調整標籤位置
在圓餅圖上,調整資料標籤位置以改善間距並為引導線騰出空間。
此示例顯示第一個資料點的值,將其標籤放置於切片外側,並使用setX和setY調整其水平與垂直偏移。這些偏移分別相對於圖表的寬度和高度。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, LegendDataLabelPosition, Presentation, SaveFormat
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.Pie, 50, 50, 200, 200)
series = chart.getChartData().getSeries()
label = series.get_Item(0).getLabels().get_Item(0)
label.getDataLabelFormat().setShowValue(True)
label.getDataLabelFormat().setPosition(LegendDataLabelPosition.OutsideEnd)
label.setX(0.71)
label.setY(0.04)
presentation.save("presentation.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()

格式化引導線
當圓餅圖標籤位於切片外部時,引導線可協助讀者將每個值對應到正確的切片。使用對比色且稍微較粗的線條可使連接更易辨識,而透明度與虛線樣式則可使線條不顯眼。
使用getLeaderLinesFormat在系列的資料標籤集合層級格式化引導線。series.getLabels().getLeaderLinesFormat().getLine() 中的設定會套用於整個集合,而非單一標籤。
此示例建立一個使用預設資料的圓餅圖,將值顯示在切片外側,並啟用setShowLeaderLines。它使用setX和setY偏移將兩個標籤遠離切片,偏移以圖表寬度和高度的比例表示。無需輸入簡報。
該線條的getFillFormat設定為實心藍色,透明度為 191/255,約 25% 透明。setWidth將粗細設定為 2 點,setDashStyle則使線條呈虛線。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, FillType, LegendDataLabelPosition, LineDashStyle, Presentation, SaveFormat
Color = jpype.JClass("java.awt.Color")
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.Pie, 80, 50, 560, 400)
chart.setLegend(False)
series = chart.getChartData().getSeries().get_Item(0)
label_format = series.getLabels().getDefaultDataLabelFormat()
label_format.setShowValue(True)
label_format.setPosition(LegendDataLabelPosition.OutsideEnd)
label_format.setShowLeaderLines(True)
# 將兩個標籤從切片向外移動更遠。
series.getLabels().get_Item(0).setX(0.10)
series.getLabels().get_Item(0).setY(-0.05)
series.getLabels().get_Item(1).setX(-0.10)
series.getLabels().get_Item(1).setY(0.05)
line = series.getLabels().getLeaderLinesFormat().getLine()
line.getFillFormat().setFillType(FillType.Solid)
color = Color(30, 90, 160, 191)
line.getFillFormat().getSolidFillColor().setColor(color)
line.setWidth(2)
line.setDashStyle(LineDashStyle.Dash)
presentation.save("FormattedLeaderLines.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
啟用引導線並不保證每個標籤都會出現線條。可見性取決於標籤位置與圖表的版面配置行為。在此示例中,兩個被移動的標籤有可見的引導線;靠近切片的標籤則不需要。
以下圖片顯示使用 Aspose.Slides 呈現的已儲存 FormattedLeaderLines.pptx:

在直條圖上方添加多行資料標籤
此示例建立一個直條圖,在繪圖區上方放置兩行資料標籤。系列 A 顯示可見的柱形,而系列 B 與系列 C 提供額外的標籤。透過移除填充與輪廓,隱藏它們的柱形。ChartSeriesGroup.setOverlap 方法將所有三個系列對齊至相同的類別中心。
ChartPlotArea 設定為標籤列保留空間。經過Chart.validateChartLayout計算預設位置後,DataLabel.setX與DataLabel.setY保留水平對齊並套用垂直偏移,以將標籤排列成兩行。這些數字仍為連結至系列值的資料標籤;僅行標題為獨立的文字圖形。
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import ChartType, FillType, LayoutTargetType, LegendDataLabelPosition, Presentation, SaveFormat, ShapeType
Color = jpype.JClass("java.awt.Color")
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 40, 40, 640, 200)
chart.setTitle(False)
chart.setLegend(False)
chart.getTextFormat().getPortionFormat().setFontHeight(12)
chart.getChartData().getSeries().clear()
chart.getChartData().getCategories().clear()
workbook = chart.getChartData().getChartDataWorkbook()
workbook.clear(0)
categories = ["North", "South", "East", "West"]
series_names = ["Series A", "Series B", "Series C"]
series_values = [[35, 42, 28, 47], [22, 31, 19, 26], [12, 16, 14, 18]]
for category_index, category in enumerate(categories):
category_cell = workbook.getCell(0, category_index + 1, 0, category)
chart.getChartData().getCategories().add(category_cell)
for series_index, series_name in enumerate(series_names):
series_cell = workbook.getCell(0, 0, series_index + 1, series_name)
series = chart.getChartData().getSeries().add(series_cell, ChartType.ClusteredColumn)
for category_index, value in enumerate(series_values[series_index]):
value_cell = workbook.getCell(0, category_index + 1, series_index + 1, jpype.JDouble(value))
series.getDataPoints().addDataPointForBarSeries(value_cell)
if series_index > 0:
# 隱藏 B 與 C 的欄位,但保留它們的資料標籤。
series.getFormat().getFill().setFillType(FillType.NoFill)
series.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill)
label_format = series.getLabels().getDefaultDataLabelFormat()
label_format.setShowValue(True)
label_format.getTextFormat().getPortionFormat().setFontHeight(12)
label_fill = label_format.getTextFormat().getPortionFormat().getFillFormat()
label_fill.setFillType(FillType.Solid)
label_fill.getSolidFillColor().setColor(Color.BLACK)
label_format.setPosition(LegendDataLabelPosition.InsideBase)
# 讓所有三個系列對齊至相同的類別中心。
chart.getChartData().getSeries().get_Item(0).getParentSeriesGroup().setOverlap(jpype.JByte(100))
# 為此緊湊範例使用較少的格線。
chart.getAxes().getVerticalAxis().setAutomaticMajorUnit(False)
chart.getAxes().getVerticalAxis().setMajorUnit(10)
# 為兩列資料標籤在圖表區上方保留空間。
chart.getPlotArea().setLayoutTargetType(LayoutTargetType.Inner)
chart.getPlotArea().setX(0.15)
chart.getPlotArea().setY(0.32)
chart.getPlotArea().setWidth(0.80)
chart.getPlotArea().setHeight(0.48)
chart.validateChartLayout()
for series_index in range(1, len(series_names)):
series = chart.getChartData().getSeries().get_Item(series_index)
row_top = 0.15 if series_index == 1 else 0.03
for category_index in range(len(categories)):
data_label = series.getDataPoints().get_Item(category_index).getLabel()
# 保持預設的水平位置。Y 是相對於
# 預設標籤位置的偏移,以圖表高度的比例表示。
data_label.setX(0)
data_label.setY(row_top - data_label.getActualY() / chart.getHeight())
# 只有列標題是獨立的文字圖形。
heading_y = chart.getY() + row_top * chart.getHeight()
row_heading = slide.getShapes().addAutoShape(ShapeType.Rectangle, chart.getX(), heading_y, 85, 18)
row_heading.getFillFormat().setFillType(FillType.NoFill)
row_heading.getLineFormat().getFillFormat().setFillType(FillType.NoFill)
row_heading.addTextFrame(series_names[series_index])
row_heading.getTextFrame().getTextFrameFormat().setMarginTop(0)
row_heading.getTextFrame().getTextFrameFormat().setMarginBottom(0)
heading_format = row_heading.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat()
heading_format.setFontHeight(12)
heading_format.getFillFormat().setFillType(FillType.Solid)
heading_format.getFillFormat().getSolidFillColor().setColor(Color.BLACK)
presentation.save("multiple-rows-of-labels.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()

常見問題
如何防止在密集圖表上資料標籤重疊?
結合自動標籤放置、引導線與縮小字型大小;必要時,可隱藏某些欄位(例如類別),或僅對極端值或關鍵點顯示標籤。
如何僅對零、負值或空值停用標籤?
在啟用標籤前篩選資料點,並根據定義的規則關閉對值為 0、負值或缺失值的顯示。
如何在匯出為 PDF/圖片時確保標籤樣式一致?
明確設定字體族與大小,並確認渲染環境中有該字體,以避免使用備用字體。

