Coder Social home page Coder Social logo

colorbar without overlap about paxplot HOT 2 OPEN

kravitsjacob avatar kravitsjacob commented on September 21, 2024
colorbar without overlap

from paxplot.

Comments (2)

kravitsjacob avatar kravitsjacob commented on September 21, 2024

Hey Steffan,

I hope you are well. Thank you for the great question! Here is a hacky workaround using the currently unsupported subplots_adjust function (gasp):

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
plt.subplots_adjust(right=0.8)  # Adding whitespace
color_col = 5
paxfig.add_colorbar(
    ax_idx=color_col,
    cmap='viridis',
    colorbar_kwargs={
        'label': cols[color_col],
        'fraction': 0.65,  # moving colorbar
        'anchor': (4.5, 1.0),  # moving colorbar
    }
)
paxfig.set_size_inches(8, 4)

plt.show()

issue

Long-term, it would be great to actually address the overlapping colorbar/legend issue. Under the hood, paxplot creates an additional subplot but in the case of long tick labels on the last axis (in your example) this approach yields the overlapping you describe. Additionally, support for tight_layout would also be great, as you mentioned.

If you or anyone reading this thread wants to take on either of these issues, I would be happy to support your efforts!

from paxplot.

SteffenMeinecke avatar SteffenMeinecke commented on September 21, 2024

Thanks @kravitsjacob for your answers and ideas! I would let the issue open to allow others to take up the ideas and contributing.

from paxplot.

Related Issues (8)

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.