Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set different axis scales in the radar chart #65

Closed
jingyao16 opened this issue Apr 11, 2024 · 5 comments
Closed

Set different axis scales in the radar chart #65

jingyao16 opened this issue Apr 11, 2024 · 5 comments
Labels
question Further information is requested

Comments

@jingyao16
Copy link

jingyao16 commented Apr 11, 2024

hi,

thanks for your wonderful contribution.

Q: Can I use different axes in the radar chart?

@jingyao16 jingyao16 changed the title different axes in the radar chat different axes in the radar chart Apr 11, 2024
@moshi4
Copy link
Owner

moshi4 commented Apr 11, 2024

Hi @jingyao16,

The question is too brief and I am not sure if I understand exactly what is being asked.
Do you want a plot like the example below?

Code Example

from pycirclize import Circos
import pandas as pd
import matplotlib.pyplot as plt

# Create RPG jobs parameter dataframe (4 jobs, 8 parameters)
df = pd.DataFrame(
    data=[
        [80, 80, 80, 80, 80, 80, 80, 80],
        [90, 20, 95, 95, 30, 30, 80, 70],
        [60, 90, 20, 20, 100, 90, 50, 70],
        [70, 50, 60, 40, 60, 40, 100, 60],
    ],
    index=["Hero", "Warrior", "Wizard", "Assassin"],
    columns=["HP", "MP", "ATK", "DEF", "SP.ATK", "SP.DEF", "SPD", "LUK"],
)
print(df)

# Create 2 x 2 subplots
fig = plt.figure(figsize=(16, 16), dpi=100)
fig.subplots(2, 2, subplot_kw=dict(polar=True))
fig.subplots_adjust(wspace=0.15, hspace=0.15)

# Plot radar chart into subplots for each target
for target_name, ax in zip(df.index, fig.axes):
    target_df = df.loc[[target_name]]

    # Initialize Circos instance for radar chart plot
    circos = Circos.radar_chart(
        target_df,
        vmax=100,
        marker_size=6,
        cmap=dict(Hero="salmon", Warrior="skyblue", Wizard="lime", Assassin="magenta"),
        grid_interval_ratio=0.2,
        line_kws_handler=lambda _: dict(lw=2, ls="solid"),
        marker_kws_handler=lambda _: dict(marker="D", ec="grey", lw=0.5),
    )

    # Plot figure & set legend on upper right
    circos.plotfig(ax=ax)
    circos.ax.legend(loc="upper right", fontsize=10)

fig.savefig("example.png")

example.png

example

FYI: https://moshi4.github.io/pyCirclize/plot_tips/#subplots

@jingyao16
Copy link
Author

Thanks for your prompt reply.

However, I supply my question, how to set axes with different scales in one plot?

For example, I want some axes to be linear but with different intervals like [0,20,40] and [1,5,7], and some axes to be logarithmic ones like [1, 10, 100].

@moshi4
Copy link
Owner

moshi4 commented Apr 15, 2024

how to set axes with different scales in one plot?

There is no function in pyCirclize to set different axis scales to radar charts.
I think that setting different axis scales for radar charts should be avoided, so I have no plans to implement that functionality.

@moshi4 moshi4 closed this as completed Apr 15, 2024
@moshi4 moshi4 changed the title different axes in the radar chart Set different axis scales in the radar chart Apr 15, 2024
@moshi4 moshi4 reopened this Apr 15, 2024
@moshi4
Copy link
Owner

moshi4 commented Apr 15, 2024

Maybe my previous answer was an incorrect understanding of the question. I interpreted your question as 2. and gave an answer, but would 1. be the correct interpretation?

  1. Change the scale for the entire axis in the radar chart
  2. Change multiple scales for each axis in the radar chart

The vmax and grid_interval_ratio arguments of the Circos.radar_chart() method can be used to change the scale for the entire axis. I plan to allow the vmin argument to be set as well in the next release. It may be a bit difficult to implement to support logarithms.

e.g. vmax=200, grid_interval_ratio=0.25 => interval=[0, 50, 100, 150, 200]

@moshi4 moshi4 closed this as completed Apr 20, 2024
@jingyao16
Copy link
Author

Thanks for your reply.

Yes, my question is actually to change the scale for multiple axes in one radar chart. Get it. No worry, I can handle it by manually post-precessing.

@moshi4 moshi4 added the question Further information is requested label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants