kravitsjacob / paxplot

Paxplot is a Python visualization library for parallel coordinate plots based on matplotlib.
https://kravitsjacob.github.io/paxplot/
MIT License
10 stars 1 forks source link

Changing figure size and fontsize #24

Open Atulsingh92 opened 1 year ago

Atulsingh92 commented 1 year ago

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?

kravitsjacob commented 1 year ago

Great question! There are ways to set sizes matplotlib-wide as found in this response here, but I tend to like more granularity:

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

# Import data
path_to_data = paxplot.datasets.tradeoff()
df = pd.read_csv(path_to_data)
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 = 0
paxfig.add_colorbar(
    ax_idx=color_col,
    cmap='viridis',
    colorbar_kwargs={'label': cols[color_col]}
)

# Changing figure size
paxfig.set_size_inches(11, 3)
paxfig.subplots_adjust(left=0.1, bottom=0.2, right=0.9, top=0.9)  # Padding

# Change tick size
tick_size = 20
for ax in paxfig.axes:
    ax.tick_params(axis="y", labelsize=tick_size)

# Change label size
label_size = 30
for ax in paxfig.axes:
    ax.tick_params(axis="x", labelsize=label_size)

# Display
plt.show()

fig