Generating Graphics with Data Plotly in QGIS 3

In order to give a bit of continuity to the theme of the previous post, now I’m going to show the experience of trying the plugin “DataPlotly”, which I found interesting, especially for its versatility for generating graphics.

Data Source

To demonstrate the advantages of the plugin we are going to use the same data of the previous post, but with the difference that now we are including an additional field that represents the values of altitude of the considered populated centers; these data have been obtained using the analysis tool “Point samplig Tool“, starting from a raster layer of altitude, the procedure can be reviewed here.

Figure 1: A column was added with altitude data from populated centres.

DataPlotly Features

It is important to mention that the “DataPlotly” plugin allows the creation of D3-style graphics (Data-Driven Documents) and thanks to the graphics library based on JavaScript available from Plotly along with the Python API, we can produce a varied group of them.

These graphics have the characteristic that they are dynamic and interactive, that is to say that it is easy to make approaches for example, also to be able to give us more information when passing on them with the mouse, in short we must emphasize the facility that we have for its edition before obtaining our final product.

Installation

DataPlotly is currently only available for the development version of QGIS, so we can test it before the new version 3.0 of QGIS is released. The installation of QGIS is easy from our add-ons administrator. Once installed in plugin, we will see it located in the toolbar ready to work with our data.

Figure 2: View of the Data Plotly plugin for installation

Knowing Data Plotly

When we activate the plugin, a window appears, which has two permanent elements, the first at the top, related to the selection of the type of graph to develop (Plot Type) and the second at the bottom, which gives us the option to generate more than one graph in a view (SubPlots), which can be represented in rows or columns (Figure 3).

Then we can see that the window is subdivided into 5 tabs, the first called “Plot Properties“, which defines the data layer to use and indicate the variables to use, ie the data fields to be represented (varies depending on the type of graphic), likewise, allows us to define the type of markers to use (points, lines or points and lines), then the characteristics of these markers, coloring and the possibility of considering the use of transparencies.

Figure 3: Data Plotly window with options to configure our graphic

In the second tab called “Plot Customizations“, we can finish configuring our chart, adding the legend, entering titles to the chart, label the axes of the chart, also, we can indicate the additional information we want to visualize, which will be shown when passing the mouse by the markers of our chart (Figure 4).

After making the configuration of our graph, you would be ready to add it to a repository or container of graphs, clicking the button “Add Plot to Basket“.

Figure 4: View of the tab to edit our chart

Precisely, our next tab called “Plot Basket” allows us to manage our graphics, especially if we want to show more than one at a time. Keep in mind that when you make any changes in the first two tabs, so that we can see them must be added to this container of graphics, from there we can go removing past graphics, to do so just select from the table and then click on the button “Remove Single Plot From List“.

Figure 5: View of the generated graphics container

Finally and having clear what we want to show in our graph, we can click on the “Draw Plot” button, as shown in Figure 5.

Then we can see that the next tab called “Help“, shows us the help needed depending on the type of graphic chosen, which allows us to guide us to know all the options available.

Finally the tab “Raw Plot“, shows what would be the source code generated from our graphic, it is in HTML text format, which we can copy and save with that extension and then view it in our web browser.

Figure 6: View of the plugin help and the generated html code

Dynamic Graphics

In this part we are going to show some examples of the graphics that can be elaborated with this plugin, for it we will begin with the type “Scatter Plot“. In itself, we will take this type of graph as a model, with the purpose of showing the dynamism and the interactivity that can be achieved with the elaborated graph.

Figure 7: Editing our graphic including titles and labeling to the axes
Figure 8: Option to edit the texts to be shown when passing the mouse and a “RangeSlider”, which allows us to select a range of data that can be displayed.
Figure 9: Options for displaying values when selected supported by dotted lines
Figure 10: You can apply selection in box or loop type, highlighting a group of data
Figure 11: You can move and zoom in on an area of interest.

Other Types of Possible Charts

Although I am not going to interpret the graphs, if I would like to show you that depending on our data, it has been possible to elaborate another group of graphs, which are presented in the following figures.

Figure 12: Chart or Box Diagram (Based on quartiles and showing the mean)
Figure 13: View of a simple histogram
Figure 14: Pie chart, grouping population data by categories
Figure 15: View of a 2D Histogram Chart
Figure 16: View of a Polar Chart
Figure 17: View of a Chart or Ternary Diagram (use of three variables)
Figure 18: View of a Contour Chart

Combining Graphics

As we indicated previously, we can compose more than one type of graph at a time, for it we must go generating and editing our types of graphics, then add them to our tray (basket), do not forget to select the option to generate “SubPlots”. It is important to note that not all types of graphics support this option.

Figure 19: Combining three chart types

Inserting Graphics to Our Map

As a final step we are going to insert it in our map with which we have been working, for it previously, as shown in Figure 19, in the lower part of the graphics there is the option to export it both as an image and in html format. Within our map printing designer, simply for our case, we add as an image for the pie chart and as an HTML frame to the image with the three graphics combined.

Figure 20: Graphics added to our map

All right, now our map can show more information with the graphics added.

Translated from: Carbajallosa

1 thought on “Generating Graphics with Data Plotly in QGIS 3”

  1. Hi,
    I am a beginner. I have generated a pie chart but don’t understand how to customize the legend. I am using the Data Plotly plugin in QGIS 3.10.
    Thanks

Comments are closed.

Discover more from GIS Crack

Subscribe now to keep reading and get access to the full archive.

Continue reading