Coder Social home page Coder Social logo

kravitsjacob / paxplot Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 1.9 MB

Paxplot is a Python visualization library for parallel coordinate plots based on matplotlib.

Home Page: https://kravitsjacob.github.io/paxplot/

License: MIT License

Python 100.00%
parallel-coordinates-plot matplotlib multi-objective high-dimensional-data

paxplot's Introduction

PyPI GitHub Workflow Status GitHub license

Paxplot

Paxplot is a Python visualization library for parallel coordinate plots based on matplotlib.

Check out our homepage for more information.

Installation

The latest stable release (and required dependencies) can be installed from PyPI:

pip install paxplot

For addition installation instructions, see the Getting Started documentation.

Reporting Bugs

Please report all bugs using issues.

Contributing

Paxplot welcomes contributions! Users familiar with matplotlib should have no problem using/contributing to this project.

  1. We recommend conda to manage environments and ensure consistent results. Download miniconda and ensure you can activate it from your terminal by running $ conda activate
    • Depending on system configuration, this can be an involved process. Here is a recommended thread.
  2. Clone the repository using $ git clone https://github.com/kravitsjacob/paxplot.git
  3. Change to the current working directory using $ cd paxplot
  4. Install the development environment $ conda env create -f environment.yml
  5. Activate the environmnet $ conda activate paxplot
  6. Install an editable version of paxplot $ pip install --editable .
  7. Paxplot uses test-driven development. All changes to Paxplot must pass the tests in the testing folder. All new features should have associated tests.

paxplot's People

Contributors

jakeval avatar kravitsjacob avatar nelerey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nelerey

paxplot's Issues

Changing figure size and fontsize

Hi,
Perhaps a simple question, but was unable to change the figure size as well as the fontsize of the labels of various axes of the parallel plots. (Referring to the basic pandas example here).
Could you please suggest something regarding the same?

colorbar without overlap

Dear @kravitsjacob,
thank you very much for this small but smart python package.

I try to use it as explained in the pandas example. Unfortunately, with my data set I get an overlap of the figure with the colormap. How can that be solved? (In other contexts plt.tight_layout() may help but not here.)
A solution increasing the width as much as needed, e.g. paxfig.set_figwidth(18), is undesired since it needs to much space.

The example code:

import pandas as pd
import matplotlib.pyplot as plt
import paxplot

json_str = '{"$v_{m_{0}}$":{"0":1.05101414,"1":0.97541944,"2":1.02250952,"3":1.05724531,"4":0.91881114,"5":1.00289782,"6":1.02356087,"7":0.91879598,"8":0.91856527,"9":1.05471083,"10":1.03512956,"11":1.01495961,"12":0.99814463,"13":1.08194644,"14":1.00435071,"15":0.91008701,"16":1.02191995,"17":1.0104185,"18":1.05577619,"19":1.03793584},"$v_{m_{1}}$":{"0":1.08675354,"1":0.99289773,"2":1.0006575,"3":1.03279003,"4":1.04013416,"5":1.00186099,"6":0.94705512,"7":1.08785596,"8":0.9901675,"9":1.03153871,"10":1.00552627,"11":0.97142502,"12":1.0635523,"13":0.94439644,"14":1.04267524,"15":1.00328082,"16":0.96776328,"17":1.05307138,"18":1.06106298,"19":1.04153575},"$v_{m_{2}}$":{"0":1.06366783,"1":0.91104843,"2":1.06438557,"3":1.00671504,"4":1.05875128,"5":0.97205114,"6":1.05476759,"7":0.99542596,"8":0.95052276,"9":1.02192044,"10":0.9318766,"11":0.92399757,"12":1.01605039,"13":1.0046992,"14":1.02006368,"15":1.04490573,"16":0.95427917,"17":0.92809566,"18":1.01760408,"19":1.06606671},"$v_{m_{3}}$":{"0":1.07216311,"1":0.97654954,"2":1.03222464,"3":0.96508126,"4":0.92882952,"5":0.9553515,"6":1.02212038,"7":0.99203902,"8":1.0135808,"9":1.07826395,"10":1.0875509,"11":1.02785425,"12":1.03946075,"13":1.04979572,"14":1.04030671,"15":1.07928366,"16":0.94665728,"17":1.02104275,"18":1.04965773,"19":0.97794591},"$v_{m_{4}}$":{"0":0.96261164,"1":0.98230649,"2":0.99018279,"3":0.91334141,"4":1.0495412,"5":1.04518659,"6":1.07116521,"7":1.00761336,"8":0.95882059,"9":1.05051721,"10":0.95355408,"11":0.94120487,"12":0.91258196,"13":1.01900706,"14":0.94362856,"15":1.03923165,"16":0.99024211,"17":0.95139986,"18":1.00734866,"19":0.98286251},"results":{"0":-33488.121893849,"1":3980.888057873,"2":-11523.4361694497,"3":16582.4829596293,"4":-24886.4934994639,"5":-2551.3204885725,"6":-1097.4260832155,"7":4460.7742568187,"8":441.248979536,"9":-435.2766055767,"10":-19832.8660960374,"11":-19358.1526127029,"12":-37944.4309613923,"13":-12791.378116259,"14":-28921.1231681309,"15":3990.7823822596,"16":1037.0001667862,"17":-9150.0172480353,"18":-11273.0333321415,"19":22697.3994558519}}'

# Import data
df = pd.read_json(json_str)
cols = df.columns

# Create figure
paxfig = paxplot.pax_parallel(n_axes=len(cols))
paxfig.plot(df.to_numpy())

# Add labels
paxfig.set_labels(cols)

# Add colorbar
color_col = 5
paxfig.add_colorbar(
    ax_idx=color_col,
    cmap='viridis',
    colorbar_kwargs={'label': cols[color_col]}
)

plt.show()

Paxplot as a sublot

Is there a way to use paxplot as a subplot in a figure that contains multiple subplots?

Improper line placement on plot with set_ticks

Hi,
The column with $N_{plates}$ is essentially 0, however the comparison I am making this plot with, has $N_{plates}$ as [0,1,2,3].
Hence I also want [0,1,2,3] in this plot for $N_{plates}$
image

I've achieved the above with

paxfig.set_ticks(ax_idx = 6,
                  ticks  = [0, 1, 2],
                  labels = ['0', '1', '2'])

Could anyone please suggest a way such that zero is at the bottom of the line drawn? and I can get 4 ticks of [0,1,2,3]??

Set log axis for some parameters

Hello,

I have the code below to create a parallel coordinates plot

paxfig = paxplot.pax_parallel(n_axes=len(cols))
paxfig.plot(df.to_numpy())

paxfig.set_labels(column_names)

paxfig.set_size_inches(12, 7)
paxfig.subplots_adjust(left=0.1, bottom=0.2, right=0.9, top=0.9)

color_col = 5
paxfig.add_colorbar(
ax_idx=color_col,
cmap='jet',
colorbar_kwargs={'label': r"$L_{MSE}$ Validation"}
)

Is it possible to have for some of the parameters (e.g. the last two) log scale in the axis in order to be able to see them better?

Screenshot 2023-12-27 at 20 28 49

Draw a grouped parallel coordinate plot with 2 sets of data

Hi,
I want to draw a grouped parallel coordinate plot with 2 sets of data in a graph, with each of the 2 sets of data represented in a different colour (using a single colour for each category, not a colorbar), and display the legend, and also, put the legend directly below the figure, not on the right side. Is there any way to achieve this?
Snipaste_2024-04-07_15-47-54

Minor mistake in error message + feature request

I encountered a mistaken error message when trying to do something that does not work in the first place.

paxfig = paxplot.pax_parallel(n_axes=len(scoredict.keys()))
print(len(scoredict.keys()) ) # 7

data = df_scores[["structure"] + list(scoredict.keys())].to_numpy()  
print(data.shape)  # (1566, 8), so len(data[0]) is 8

paxfig.plot(data)
print(len(paxfig.axes))  # 7

The error message resulting from this is:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-26-f4ee5b26134c> in <module>
      5 data = df_scores[["structure"] + list(scoredict.keys())].to_numpy()
      6 
----> 7 paxfig.plot(data)
      8 
      9 paxfig.set_labels(list(scoredict.keys()))

~/.conda/envs/new-ada-env/lib/python3.8/site-packages/paxplot/core.py in wrapper(*args, **kwargs)
    709         original_flag_value = fig._show_unsafe_warning
    710         fig._show_unsafe_warning = False
--> 711         result = func(*args, **kwargs)
    712         fig._show_unsafe_warning = original_flag_value
    713         return result

~/.conda/envs/new-ada-env/lib/python3.8/site-packages/paxplot/core.py in plot(self, data)
    190             )
    191         **elif len(data[0]) > len(self.axes):
--> 192             raise ValueError(
    193                 'Supplied data has fewer columns than figure. Please recreate '
    194                 'paxfigure with appropriate n_axes'**

ValueError: Supplied data has fewer columns than figure. Please recreate paxfigure with appropriate n_axes

So either the elif test should be reversed, or the text should say "Supplied data has more columns than figure".

This is also a feature request: it would be convenient to be able to use one column, containing labels / categorical data (str) only for coloring, without having to also plot it on a separate axis and convert to numerical labels.

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.