Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Data Visualization: 5 Ways To Be An Enterprise-Grade Master!

python4delphi data visualization

Photo by Chris Liverani on Unsplash

In this article, you’ll learn what data visualization is, how to start learning data visualization in windows, using Python Windows GUI Builder with data visualization, How to use Matplotlib, Seaborn, Bokeh, NetworkX, and Plotly Python libraries for Data Visualization Tasks, Python GUI data visualization results, and many more.

What is data visualization?

Data Visualization is an interdisciplinary field that deals with the graphic representation of data. It is a particularly efficient way of communication when the data is diverse and potentially complex.

Visualizing data, whether in charts, graphs, or some other form, is important because it can give meaning to the data for a broader audience. “Visualization gives us a way to parse and understand data so that we can add it to our stories, we can incorporate it into our thinking,” says Ellie Fields, Senior Vice President of product development at Tableau.

How do I start learning data visualization in Windows?

With a plethora of online tools and software packages for Data Visualization available, online classes, and resources to help you hone your skills, the entry barrier for creating compelling Data Visualization is lower than ever before. That means you can become proficient in presenting data visually “without a real background” in computer science, data science, or programming.

But with so many options, finding a place to start can be overwhelming. In this tutorial, we’ll introduce you to how to integrate any Python’s Data Visualization libraries with Embarcadero’s Delphi, using Python4Delphi (P4D) to get you started in creating Windows GUI apps.

How does Python4Delphi help with data visualization?

P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python Data Visualization applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials.

How to use Matplotlib, Seaborn, Bokeh, NetworkX, and Plotly Python libraries to perform data visualization tasks

All of the libraries we show in this demo can be integrated with Python4Delphi for you to easily create Windows Apps with data visualization capabilities.

Prerequisites: Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth.

Time to get started!

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

Open Demo01dproj

1. How do I Visualize Data with Matplotlib in Windows? 

Matplotlib is one of the most popular and oldest data visualization libraries in Python which is commonly used in exploratory data analysis and machine learning. In data science and machine learning, Matplotlib helps us to gain insights from a huge amount of data through different data visualization techniques.

With the growing demand for data science and analytics skill sets, visualizing data programmatically is one of the most crucial tasks these days. You can easily solve these tasks by combining the Matplotlib library with Python4Delphi (P4D). Matplotlib can be used in Python scripts, in the Python and IPython shell, on web application servers, and various graphical user interface toolkits (in this post, Python GUI by Delphi’s VCL using P4D)!

After installing Python4Delphi properly, you can get Matplotlib using pip or easy install to your command prompt:

[crayon-673a28687683c357960733/]

and don’t forget to put the path where your Matplotlib installed, to the System Environment Variables, shown in this example:

[crayon-673a286876845635416589/]

The following is a code example of Matplotlib to create an annotated heatmap (run this inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-673a286876847473673975/]

Here is the result in Python GUI

Matplotlib Demo with Python4Delphi in Windows

Matplotlib is a comprehensive Python library for creating static, animated, and interactive visualizations. Matplotlib produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms.

Read more: https://pythongui.org/learn-to-work-with-real-world-graphics-using-the-python-matplotlib-library-in-a-delphi-windows-app/

2. How do I visualize data with Seaborn in Windows?

Seaborn is a library for making statistical graphics in Python. It is built on top of Matplotlib and closely integrated with pandas data structures. Seaborn will enhance the Matplotlib plotting functionalities.

Here is some of the functionality offered by Seaborn:

Do you want to improve Matplotlib plots using Seaborn?

For example, you could create a Scatterplot with varying point sizes and hues in the Windows GUI app?

This section will show you how to get started!

First, here is how you can get Seaborn :

[crayon-673a286876848531595737/]

The following is an introductory example of Seaborn to a Scatterplot with varying point sizes and hues (run this inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-673a28687684b637388835/]

Here is the Seaborn result in the Python GUI:

Seaborn Demo with Python4Delphi in Windows

Seaborn aims to make visualization a central part of exploring and understanding data. Its dataset-oriented plotting functions operate on data frames and arrays containing whole datasets and internally perform the necessary semantic mapping and statistical aggregation to produce informative plots.

3. How do I visualize data with Bokeh in Windows?

Bokeh is an interactive visualization library to be shown in modern web browsers. It provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets. Bokeh can help anyone who would like to quickly and easily make interactive plots, dashboards, and data applications.

At a glance, Bokeh provides us with:

Bokeh makes it simple to create common plots but also can handle custom or specialized use-cases.

Tools and widgets let you and your audience probe “what if” scenarios or drill-down into the details of your data.

Plots, dashboards, and apps can be published on web pages or Jupyter notebooks.

Work in Python close to all the PyData tools you are already familiar with.

You can always add custom JavaScript to support advanced or specialized cases.

Everything, including the Bokeh server, is licensed under the BSD license and available on GitHub.

Getting and installing Bokeh

This section will guide you to combine Python4Delphi with the Bokeh library, inside Delphi and C++Builder, from installing Bokeh with pip to how to make an interactive plot of the interactive of an unemployment rate.

First, here is how you can get Bokeh

[crayon-673a28687684c123321364/]

Using Bokeh for Python data visualization

The following is a code example of Bokeh to produce an interactive plot of the unemployment rate in Texas (run this inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-673a286876850157892943/]

Bokeh Python4Delphi results

Bokeh Demo with Python4Delphi in Windows

4. How do I visualize data with NetworkX in Windows?

NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

Briefly, NetworkX provides us with:

Here is how you can get NetworkX

[crayon-673a286876852644103994/]

The following is a code example of NetworkX to create a Random Geometric Graph (run this inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-673a286876853857671963/]

NetworkX Data Visualization Result

NetworkX Demo with Python4Delphi in Windows

5. How do I visualize data with Plotly in Windows? 

Plotly or plotly.py is an interactive, open-source, and browser-based data visualization library for Python.

Built on top of plotly.js, plotly.py is a high-level, declarative charting library. plotly.js ships with over 30 chart types, including scientific charts, 3D graphs, statistical charts, SVG maps, financial charts, and more. plotly.py is MIT Licensed.

Are you looking for a simple, flexible, and powerful data visualization library, and build a nice GUI for it? You can deliver enterprise-grade and publication-quality graphs easily by combining Plotly and Python4Delphi library, inside Delphi and C++Builder.

Installing Plotly for Data Visualization

[crayon-673a286876857431509661/]

A Plotly Python code example

The following is a code example of Plotly to visualize the famous 1962-2006 Walmart Store Openings dataset (run this inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-673a286876859520561576/]

Using Python and Plotly for powerful data visualization

Plotly Demo with Python4Delphi in Windows

If you are interested in machine learning, artificial intelligence, or data science, then take a look at a new way to write chief Delphi code against Python libraries in this article.

Want to know some more? Then check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.

Exit mobile version