Skip to content

colorbar without overlap #20

Description

@SteffenMeinecke

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()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions