在生产中测试无水印。
随时随地为您服务。
获取30天的完全功能产品。
几分钟内即可启动和运行。
在您的产品试用期间,全面访问我们的支持工程团队。
Pygal 是一个超级强大的 Python 包和动态 SVG 图表库,用于创建交互式图表和绘图、可缩放的 SVG 图表和图形。Pygal 拥有非常易于使用的 API,其灵活性足以生成多种格式的图表。 使 Pygal 在数据方面非常强大的原因之一是可视化和报告——从最基本的到专家级的任务,甚至是预测——包括从几行代码中轻松构建漂亮图表的能力。
然而,Python 包 IronPDF 专门设计用于处理涉及 PDF 文档处理的场景。 它提供了一个接口,开发人员可以通过该接口创建、编辑和显示PDF。 它允许开发人员生成动态PDF报告,合并多个PDF文档,从PDF表单中提取数据,并动态添加基于文本和图形的内容。 当应用程序需要从数据库提取的材料或用户输入生成的材料动态生成PDF时,这个Python库非常有用。
Pygal 和 IronPDF 的组合库为开发者提供了一整套工具,以通过高级图形功能和可靠的 PDF 文档管理扩展 Python 应用程序。 这些库结合起来可以让开发人员生成带有折线图和数据可视化的复杂数据驱动报告。
Pygal是一个用于在 SVG 中创建交互式图表的 Python 包。 它拥有一个极其简单且强大的API,使开发人员的工作变得非常轻松,可以创建交互式图表:从最基本的饼图和条形图到更复杂的简单折线图和图表。 其中一个更有趣的功能是,它可以用极少的代码行轻松生成精美的图表,因此对新手和专家开发者来说都是非常有用的工具包。
Pygal库的最大优势之一可能是处理大型数据集而不影响Web应用程序的响应速度。 它通过工具提示、图例和可点击的数据点等功能提供丰富的终端用户交互。 响应式 Web 应用程序:使用 Pygal 库生成的所有图表默认是响应式的; 因此内置样式可以轻松适应不同的屏幕尺寸和设备。
结合Python数据处理和可视化生态系统的强大功能,Pygal以仪表板和动态报告为数据驱动的可视化提供支持。 借助Python的强大功能,Pygal可以更轻松地创建数据集并构建复杂的科学数据可视化、项目文档、商业分析或教育用途的图表。
Pygal 是 Python 中的一种附件,它基于其许多附加功能可以使图表具有互动性和引人注目。 其中一些如下:
无与伦比的图表类型支持: Pygal 支持多种类型的雷达图,因此可以实现灵活的数据可视化。 雷达图的例子包括柱状图、折线图、饼图、雷达图、点图、金字塔图、漏斗图、条形图等。
SVG代表可缩放矢量图形。 简而言之,这个想法是,使用SVG格式绘制的Pygal图表在任何比例下都能保持高质量和最佳分辨率。
互动图表: Pygal 图表可以通过工具提示、图例和可点击的数据点等功能变得互动,所有这些功能在浏览图表和比较数据时提高了用户的参与度。
自定义: Pygal 提供了许多选项,以根据用户的需求个性化饼图显示。 这包括从工具提示和标签到着色的更多内容。
默认情况下,Pygal 的所有文档和图表都是响应式设计的。 这意味着它们适合于不同种类和尺寸的屏幕和设备,因此可以在在线应用程序中完美使用。
它设计非常简单。 大多数用户通常发现创建复杂的条形图不是问题,所需的编码很少。 这一切都归功于其用户友好的API所提供的易用性,因此无论是新手还是经验丰富的开发者都可以轻松使用。
数据集成: Pygal 轻松与 Python 中著名的数据处理库集成,如 NumPy 和 Pandas。
导出选项: 除了SVG版本外,它还提供以PNG和PDF格式导出图表的功能,以便于分享和进一步使用。
灵活性: Pygal 是模块化的,因此可以轻松扩展和修改; 程序员可以在这里制作特殊类型的饼图。
使用 Pygal 设置和配置图表非常简单。 我们将首先设置环境,然后逐步开始创建图表。 以下是一个分步流程,帮助您入门。
您首先需要设置 Pygal。 您可以使用 pip 进行设置。
pip install pygal
pip install pygal
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'pip install pygal
让我们从一个非常基本的条形图开始,以确认Pygal的基础。
import pygal
# Create a bar chart
bar_chart = pygal.Bar()
# Add data to the chart
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Render chart to a file
bar_chart.render_to_file('bar_chart.svg')
import pygal
# Create a bar chart
bar_chart = pygal.Bar()
# Add data to the chart
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Render chart to a file
bar_chart.render_to_file('bar_chart.svg')
#Create a bar chart
#Add data to the chart
#Set chart title
#Render chart to a file
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'import pygal bar_chart = pygal.Bar() bar_chart.add('Apples', [5, 10, 15, 20]) bar_chart.add('Oranges', [10, 15, 20, 25]) bar_chart.title = 'Fruit Sales' bar_chart.render_to_file('bar_chart.svg')
Pygal中的高度自定义选项允许您按照自己的意愿设置图表外观。 以下是如何设置图表的一些功能的示例:
import pygal
# Create a bar chart
bar_chart = pygal.Bar()
# Add data with labels
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Set x and y axis titles
bar_chart.x_title = 'Time Period'
bar_chart.y_title = 'Quantity Sold'
# Set x labels
bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4']
# Customize colors
bar_chart.style = pygal.style.Style(
background='white',
plot_background='lightgrey',
foreground='black',
foreground_strong='darkblue',
foreground_subtle='grey',
opacity='.6',
opacity_hover='.9',
transition='400ms ease-in',
colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')
)
# Render chart to a file
bar_chart.render_to_file('custom_bar_chart.svg')
import pygal
# Create a bar chart
bar_chart = pygal.Bar()
# Add data with labels
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Set x and y axis titles
bar_chart.x_title = 'Time Period'
bar_chart.y_title = 'Quantity Sold'
# Set x labels
bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4']
# Customize colors
bar_chart.style = pygal.style.Style(
background='white',
plot_background='lightgrey',
foreground='black',
foreground_strong='darkblue',
foreground_subtle='grey',
opacity='.6',
opacity_hover='.9',
transition='400ms ease-in',
colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')
)
# Render chart to a file
bar_chart.render_to_file('custom_bar_chart.svg')
#Create a bar chart
#Add data with labels
#Set chart title
#Set x and y axis titles
#Set x labels
#Customize colors
#Render chart to a file
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'import pygal bar_chart = pygal.Bar() bar_chart.add('Apples', [5, 10, 15, 20]) bar_chart.add('Oranges', [10, 15, 20, 25]) bar_chart.title = 'Fruit Sales' bar_chart.x_title = 'Time Period' bar_chart.y_title = 'Quantity Sold' bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4'] bar_chart.style = pygal.style.Style(background='white', plot_background='lightgrey', foreground='black', foreground_strong='darkblue', foreground_subtle='grey', opacity='.6', opacity_hover='.9', transition='400ms ease-in', colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')) bar_chart.render_to_file('custom_bar_chart.svg')
首先,设置库,然后开发一个工作流程,使用Pygal创建图表,并使用IronPDF将它们包含在PDF文档中。 以下是逐步流程:
"(《世界人权宣言》)IronPDFPython模块是一个用于创建、编辑和读取PDF的精细包。 由于拥有众多功能,编写代码的人员可以使用PDF来执行广泛的可编程操作,其中还包括将HTML文件转换为PDF文件,以处理之前创建的PDF。 这将增强灵活性并使起草精美PDF报告的过程更加顺畅。 这对于实时创建和处理PDF的应用程序非常有用。
借助IronPDF的所有文档功能,任何时间点的任何HTML数据都可以快速转换为PDF文档。 除此之外,它还提供了一个平台,从网络内容直接创建极具创意和引人注目的 PDF 出版物,使用 HTML5、CSS3 和 JavaScript 的大多数最新功能。
您可以使用某些编程语言以编程方式生成全新的PDF文档,其中包括文本、图像、表格等内容。 您可以预先打开准备好的文档,然后通过使用IronPDF进行编辑来进一步自定义它们。 您始终可以添加、修改或删除任何版本 PDF 文档的内容。
它对PDF的内容有一种内在风格; 可以使用不同的字体、颜色和其他设计功能来处理复杂的布局。 此外,JavaScript 也不能用于管理 PDF 中的动态内容,因此更容易渲染 HTML 信息。
可以使用 pip 安装 IronPDF。安装命令将如下所示:
pip install ironpdf
pip install ironpdf
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'pip install ironpdf
创建一个简单的Pygal图表并写出SVG文件。在此示例中,它将创建一个柱状图。
import pygal
from ironpdf import * import warnings
warnings.filterwarnings('ignore')
License.LicenseKey = "";
# Create a bar chart
bar_chart = pygal.Bar()
# Add data with labels
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Set x and y axis titles
bar_chart.x_title = 'Time Period'
bar_chart.y_title = 'Quantity Sold'
# Set x labels
bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4']
# Customize colors
bar_chart.style = pygal.style.Style(
background='white',
plot_background='lightgrey',
foreground='black',
foreground_strong='darkblue',
foreground_subtle='grey',
opacity='.6',
opacity_hover='.9',
transition='400ms ease-in',
colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')
)
# Render chart to a file
bar_chart.render_to_file('custom_bar_chart.svg')
# Converts the images to a PDF and save it.
directory_list = List[str]()
directory_list.Add('custom_bar_chart.svg')
ImageToPdfConverter.ImageToPdf(directory_list).SaveAs("composite.pdf")
import pygal
from ironpdf import * import warnings
warnings.filterwarnings('ignore')
License.LicenseKey = "";
# Create a bar chart
bar_chart = pygal.Bar()
# Add data with labels
bar_chart.add('Apples', [5, 10, 15, 20])
bar_chart.add('Oranges', [10, 15, 20, 25])
# Set chart title
bar_chart.title = 'Fruit Sales'
# Set x and y axis titles
bar_chart.x_title = 'Time Period'
bar_chart.y_title = 'Quantity Sold'
# Set x labels
bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4']
# Customize colors
bar_chart.style = pygal.style.Style(
background='white',
plot_background='lightgrey',
foreground='black',
foreground_strong='darkblue',
foreground_subtle='grey',
opacity='.6',
opacity_hover='.9',
transition='400ms ease-in',
colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')
)
# Render chart to a file
bar_chart.render_to_file('custom_bar_chart.svg')
# Converts the images to a PDF and save it.
directory_list = List[str]()
directory_list.Add('custom_bar_chart.svg')
ImageToPdfConverter.ImageToPdf(directory_list).SaveAs("composite.pdf")
import pygal From ironpdf import * import warnings warnings.filterwarnings( 'ignore') License.LicenseKey = "";
#Create a bar chart
#Add data with labels
#Set chart title
#Set x and y axis titles
#Set x labels
#Customize colors
#Render chart to a file
#Converts the images to a PDF and save it.
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'bar_chart = pygal.Bar() bar_chart.add('Apples', [5, 10, 15, 20]) bar_chart.add('Oranges', [10, 15, 20, 25]) bar_chart.title = 'Fruit Sales' bar_chart.x_title = 'Time Period' bar_chart.y_title = 'Quantity Sold' bar_chart.x_labels = ['Q1', 'Q2', 'Q3', 'Q4'] bar_chart.style = pygal.style.Style(background='white', plot_background='lightgrey', foreground='black', foreground_strong='darkblue', foreground_subtle='grey', opacity='.6', opacity_hover='.9', transition='400ms ease-in', colors=('#E80080', '#404040', '#9BC850', '#FAB243', '#F3C300')) bar_chart.render_to_file('custom_bar_chart.svg') directory_list = List[str]() directory_list.Add('custom_bar_chart.svg') ImageToPdfConverter.ImageToPdf(directory_list).SaveAs("composite.pdf")
首先应该导入需要使用的库中的所有内容:使用pygal进行图表绘制,以及使用IronPDF生成PDF。 然后抑制一些警告以使输出干净,之后进行IronPDF的许可证密钥分配; 但是,空字符串应该保留在那里。
条形图的构建方法如下:使用 Pygal 的 Bar 类。 数据增加了“苹果”和“橙子”,并为四个季度提供了相应的值。 图表的标题是“水果销售”,折线图的 x 轴和 y 轴分别标注为“时间段”和“销售数量”。 最后,将 x 轴的标签明确定义为['第一季度', '第二季度', '第三季度', '第四季度'].
它利用了 Pygal 样式类来修改图表的外观和感觉。 有背景颜色、图表背景、文本颜色和图表颜色等设置。 其他样式甚至包括如透明度的过渡效果等参数。 图表以特定的文件名 'custom_bar_chart.svg' 渲染。
此示例使用'IronPDF'库将SVG文件转换为PDF。 首先,创建一个列表来保存SVG文件的目录路径。 然后,通过图像到 PDF 转换器类,它使用方法 ImageToPdf 将 SVG 转换为 PDF,并将其保存为“composite.pdf”。
该解决方案预计将结合Pygal在创建图表时的简便性与IronPDF在生成PDF文档时的强大功能,实现轻松将可视化数据表示和见解集成到专业报告中的工作流程。
Pygal的简单性和可定制性使得只需几行代码就能快速开发多种类型的图表。 通过将Pygal与IronPDF集成,可以轻松开发动态数据驱动的可视化,从而将它们置于一流的PDF出版物中。 IronPDF 使将这些图表转换为专业级 PDF 报告的任务变得更加容易。 因此,视觉文档、演示文稿和数据分析的报告变得相当容易,并且可以通过数据叙事进行详细阐述。 用户擅长以改进的方式呈现复杂信息,从而吸引感兴趣的读者。 使用Pygal和IronPDF进行这样的尝试,使得在为商业、学校或个人项目中的读者制作优美的教育可视化文档时,工作流程变得顺畅且提供了最佳选择。
这将在IronPDF与其他集成中非常有用铁软件产品,通过为用户提供复杂的解决方案,为客户提供更高的价值和软件解决方案。 这样做将使您更容易改进项目和流程操作的整体运作。
除了这些核心功能,IronPDF 还是一款为开发者精心编写文档的软件,活跃且定期更新。 基于上述事实,开发人员可以确信 Iron Software 将是现代软件开发项目的可靠合作伙伴。 开发人员可以尝试IronPDF 的免费试用并启用所有这些功能。 您将确保获得价值749美元的许可费用,甚至在接下来的日子里享受默示的担保。