Giter Club home page Giter Club logo

chartkra's Introduction

Introduction

pip3 install chartkra

chartkra facilitates the chart displaying on PyQt widgets by the use of matplotlib. It can easily to display the following figures:

  1. plots
  2. bars
  3. pies
  4. heatmaps

Usage

It's very easy to getting started with chartkra. What you need to do is to instantiate a chartkra object, and pass its get_widget function to PyQt Widget's addWidget function:

# initialize
chart = chartkra()
self.gridLayout.addWidget(chart.get_widget())
# draw charts
# ...

It's the same way to showing a heatmap, just need to instantiate a HeatMap object instead.

# initialize
heatmap = HeatMap()
self.gridLayout.addWidget(heatmap.get_widget())
# draw heatmap
# ...

Drawing Figures

Drawing Plots

Use function draw_plot to draw. Pass what you're going to show on x axis to listx, and what you're going to show on y axis to listy.

chart.draw_plot(listx=['12/01', '12/02', '12/03'], listy=[1, 2, 3])

Drawing Bars

Use function draw_bar to draw. Pass what you're going to show on x axis to listx, and what you're going to show on y axis to listy.

chart.draw_bar(listx=['zone1', 'zone2', 'zone3'], listy=[1, 2, 3])

Drawing Pies

Use function draw_pie to draw. The sizes and the labels reference the partition in the pie figure respectively.

chart.draw_pie(sizes=[1, 2, 3], labels=['zone1', 'zone2', 'zone3'])

Drawing Heatmaps

Example: Pedestrian Trajectory Heatmap

codes:

heatmap.set_zone(pic='office_inte.jpg', width=8.2, height=10.836, points=points)
heatmap.set_display(accuracy=25, style=plt.cm.jet, rotation=0, title='Pedestrian Trajectory Heatmap')
heatmap.set_colorbar(position='right', width='5%', padding=0.1)
heatmap.show()

When creating a heatmap, it is needed to declare the function set_zone and its arguments:

  • pic: the path of picture which you want to show in heatmap.
  • width: width of the picture(zone).
  • height: height of the picture(zone).
  • points: the points scattered in the zone, the units of each point need to be the same as the width and the height of picture(zone).

By setting up argument title and title_padding in function set_display, you can customized the title of figure and the padding between title and figure.

Accuracy

It is customized by argument accuracy in function set_display

Styles

It is customized by argument style in function set_display. The accepted styles can be found on https://matplotlib.org/examples/color/colormaps_reference.html

Orientations

It is customized by argument rotation in function set_display. The accepted values includes 0, 90, 180 and 270.

Colorbars

It is customized by assign arguments in function set_colorbar

  • position: accepted values includes top, right, left, bottom.
  • width: the width of the colorbar.
  • padding: distance between colorbar and figure.

Others

  • The showing of colorbars is not requires. The colorbars will not be showed by default if you don't declare function set_colorbar.
  • By using function disable_heatmap_layer, the figure will only display picture.
  • By using function disable_img_layer, the figure will only display heatmap layer.

Save Figure to File

In general situations, using function show would be enough for showing a figure. If you want to save the figure to file as well, just declare function show_and_save_fig instead and assign arguments filename and display resolution like:

heatmap.show_and_save_fig(filename='sample.png', dpi=150)

chartkra's People

Contributors

carterchen247 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

malikqasimali

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.