TransWikia.com

Re-ordering bar chart from Data Plotly in QGIS 3.14.16

Geographic Information Systems Asked by David Addy on June 27, 2021

I have successfully created a bar chart using Data Plotly within QGIS 3.14.16. The x axis consists of 17 place names (NAME) and the Y axis shows the value (VALUE IN £P) of one particular lease at each location, ranging from £0 to £46. This is an historical chart. However I would like the plots to be ordered by value so that the lowest value is on the left and the rest graduated to the highest value on the far right of the plot.

Is this possible? Can any kind person provide me with an expression to achieve this please?

Please see the chart shown below.1

One Answer

By default, Plotly represents your data in the order of insertion. The first inserted element has the id 0. Here is a tip to get the expected result.

enter image description here

You can also retrieve this value by creating a new field and assigning it the value $id.

enter image description here

Here is the result obtained.

enter image description here

A trick is to directly modify the file containing the attribute table (example .dbf file for the shapefile). You cannot edit this file if it is opened in QGIS. Sort the VALUE field in descending order if you want to display the data in descending order and then save. This will change the element IDs.

enter image description here

Add the layer to your project and here is the result.

enter image description here

Correct answer by Vincent Bré on June 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP