Seven Key Features You Should Know for Creating Professional Visualizations with Plotly

Author:Murphy  |  View: 27198  |  Time: 2025-03-23 11:55:17
Aleks Dorohovich in Unsplash

We are used to seeing interactive visualizations in online newspapers, and often we might wonder what tools data journalists use to create these professional-looking visualizations. The reality is that no special software is needed to create this type of visualizations; most interactive visualization libraries in Python are highly customizable, allowing for the creation of high-quality visualizations from a design perspective. In this article, we will show step-by-step how to customize an interactive visualization created in Plotly to significantly improve its design with just a few tweaks.

Original Visualization

For this article, we will use a simple visualization, such as the temporal evolution of a variable. The data to be visualized corresponds to the German population from the year 1800 to 2020. First, we will create the simplest possible visualization of the data with Plotly, without any customization. Subsequently, we will explain all the customizations used step by step, and the code for the improved visualization will be provided at the end of the article.

The data used in the visualization can be obtained from the following page.

Population of Germany 1800-2020 | Statista

You can download the file with the data and run the code from this article on your computer to obtain the same results as shown in this article. Additionally, you can continue customizing to further improve the visualization.

First, we download the data and store it in a Pandas DataFrame.

DataFrame containing the population of Germany

We start with a simple visualization created in Plotly; in this case, the visualization consists of a line graph, with no additional customization.

Original Plot without Customization

Key Features for Creating Professional Visualizations

The goal of this article is to beautify the original visualization to make it look more professional, with a style similar to those visualizations you can find in newspapers such as the Financial Times. Next, we will explain step by step each technique that has been applied to transform the visualization and make it more visually appealing.

Direct Labeling

Direct labels are a simple method to highlight specific information in a visualization. In this example, the goal is to highlight the beginning and the end of the German population over a period, from 1800 to 2020. Information for the remaining points can be observed using hoverovers. As shown in the code below, direct labels are implemented through annotations at the points of interest. Additionally, the y-axis labels have been removed to avoid overloading the visualization, as the values can be obtained from both the direct labels and also the hoverovers.

Shaded Areas

When we create a visualization that reflects a temporal evolution, highlighting certain events on the graph is sometimes interesting to provide context. Sometimes, these events occur on a specific day and are therefore visualized using a vertical line; however, in other cases, the event occurs over a period of time and should be visualized using a shaded area.

Subtitle

Visualizations in newspapers often have a title and a subtitle. One of them usually explains what is shown in the visualization, while the other conveys the key insight that the visualization provides. Annotations are used to create subtitles in the graph, as shown in the code below. The important part will be adjusting the x and y coordinates to place the annotation below the title. Another important aspect is to create the subtitles in a smaller font than the title, as shown in the visualization.

Footer

Another feature that many visualizations in newspapers or magazines typically have is information about the data source, placed in a footer below the graph. This is done in the same way as the subtitle, using annotations. As before, finding the appropriate x and y coordinates, to correctly place the annotation, will be necessary. Another important aspect is the font size, which for the footer will generally be smaller than the one used for the subtitle.

Customize Hover Effects

The default hoverovers are simply a tuple with the x and y values, as shown in the original image at the beginning of the article. These can be customized to create more detailed hoverovers. In this case, a hoverover with two lines has been created: one indicating the year and the other the population. This hoverover is much more professional than the one that was created by default.

Font Type

The default font in Plotly is Open Sans. This font looks very professional; however, there may be times when you need to customize your visualization with a different font type. I am a big fan of rounded fonts mainly because I think they look both professional and modern. For this reason, I have decided to implement a font called Rubik in the visualization. Poppins, Aptos, and Rubik are in my view, the most modern and professional fonts for visualizations. You can also try other fonts, depending on the needs or preferences of your particular project.

Background and Grids

One of the key principles for designing a good visualization is to use ink only to represent data. Therefore, a good visualization design should avoid the unnecessary use of ink. Following this guideline, we can implement changes in the visualization such as removing the background or the grids, as these elements do not provide any additional information.


Customized Visualization

The following code shows all the previously implemented changes. I invite you to try additional changes according to your preferences. The truth is that Plotly is one of the Python libraries that offers higher quality and highly customizable visualizations. In addition, these visualizations can easily be used in web apps, for example, those made with Streamlit, or even embedded in Medium articles.

Plotly Visualization Designed with a Professional Style

In this article, we have covered seven features you can use to create professional visualizations, similar to those you might see in newspapers and online publications, using Plotly. With these simple methods, you can make your visualizations look much more professional. In the given example, they have been applied to a line chart. Still, the truth is that these features can be applied to a wide variety of visualizations, significantly improving their quality. I encourage you to put them into practice in your visualizations!

Thanks for reading,

Amanda

Tags: Data Storytelling Data Visualization Plotly Python Visualization

Comment