How to implement category axis in matplotlib?

Stack Overflow Asked by fgg1991 on December 10, 2020

enter image description here

Here is what I did in PyQt with QtChart:

I have 3 columns in a dataframe, col1 is used as y-axis value, col2 is used as x-axis value. BUT col3 is used as x-axis label.

Each point has three attributes:SimErr(y), GID(integer, x axis) and Group(shown in x-axis label)

So how could I do this in matplotlib? I cannot find any class which is similar to QCatogoryAxis in QT

Here is my pyqt code:

        gaugefile = list(self.gaugefile_dict.values())[0]  # this is the dataframe
        # this dict stores the start GID and end GID for each Group
        # Like axis_init_dict[(0, 100)] = GroupA
        # axis_init_dict[(101, 200)] = GroupB
        axis_init_dict = extract_start_end_for_group(gaugefile)
        x_axis_group = QtCharts.QCategoryAxis()
        for (start, end), group in axis_init_dict.items():
            x_axis_group.append(str(group), end)
        y_axis_value = QtCharts.QValueAxis()
        y_axis_value.setRange(self.axis_range['y_min'], self.axis_range['y_max'])
        chart.addAxis(x_axis_group, Qt.AlignBottom)
        chart.addAxis(y_axis_value, Qt.AlignLeft)

Add your own answers!

Related Questions

Can i show all variable results in a div in jQuery?

0  Asked on December 5, 2021 by nippledisaster


Comparing two generics in compareTo()

2  Asked on December 5, 2021 by chalupabatmac


arranging the json file base on key value

1  Asked on December 5, 2021 by prateek-singh


Vue watch method not filtering object

3  Asked on December 5, 2021


Passing a variable between HTML pages using JavaScript

2  Asked on December 5, 2021 by robert-little


How to avoid code redundancy with JAVA generics

1  Asked on December 5, 2021 by cosimoth


Why is my project no longer updating when I write new code?

1  Asked on December 5, 2021 by stephen-horton


node https ssl your connection is not private error

2  Asked on December 5, 2021 by andrea-dattero


Nested for loop using dict

9  Asked on December 5, 2021 by purwu


React Hooks – Input loses focus when 1 character is typed in

4  Asked on December 5, 2021 by dragos-strugar


How do I build a C Python Extension for Windows using Cygwin64?

2  Asked on December 5, 2021 by zenith2198


Wificonfiguration is deprecated Android 10

1  Asked on December 5, 2021 by ahmad-idrees


Wrong tootip in chartjs

1  Asked on December 5, 2021 by thiago-scher


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP