#๐ What library/tool was used to create such a radar plot?
37 messages ยท Page 1 of 1 (latest)
@loud marten
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
what do the colours represent?
it should be doable with matplotlib or plotly, if you can share some data to be plotted and your attempts it would be helpful
Did you look here? https://matplotlib.org/stable/gallery/index.html
plotly has a coloured radar chart
https://plotly.com/python/radar-chart/
So far I have been able to make a radar plot that has the right shape and layout etc. But I cannot seem to get the colors clear and nicely blended like the original. The data itself is a small dataframe with some median values based on a clustering where the label is the 5_attr_adj column. I use this label to determine the color with my viridis color map
This is how it looks in my notebook rn
This is the current code:
df = publicly_available_medians_gdf.set_index("5_attr_adj")
attrs = df.columns.tolist()
angles = np.linspace(0, 2 * np.pi, len(attrs), endpoint=False).tolist()
angles += angles[:1]
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
ax.set_theta_offset(np.pi / 2)
ax.set_theta_direction(-1)
viridis_frequently_used = plt.get_cmap("viridis", len(dim_red_results_publicly_available["5_attr_adj"].unique()))
colors = viridis_frequently_used(np.linspace(0, 1, len(df)))
for i, (_, row) in enumerate(df.iterrows()):
values = row.tolist()
values += values[:1]
ax.plot(angles, values, color=colors[i], alpha=0.7, linewidth=2)
ax.fill(angles, values, color=colors[i], alpha=0.1)
y_ticks = [0.2, 0.4, 0.6, 0.8, 1.0]
ax.set_yticks(y_ticks)
ax.set_yticklabels([str(y) for y in y_ticks], fontsize=10, color="gray")
ax.set_xticks(angles[:-1])
ax.set_xticklabels(attrs, fontsize=10)
ax.yaxis.grid(True)
plt.show()
would you mind sharing the data as well? just so it's easier to run the code
Was about to make the export ๐
csv files can be shared in this chat ๐
Please react with โ
to upload your file(s) to our paste bin, which is more accessible for some users.
yeah ๐ what is publicly_available_medians_gdf and dim_red_results_publicly_available?
got your image
Yeah thats what I get rn too, just need to know how to blend these colors and make the transitions nicer
just setting linewidth=0 already makes this which I think is closer to what you were looking for
choosing the "RdBu_r" colormap gives
Wish that I could use that, but I am stuck with Viridis
I have to reproduce for a uni project, but the prof prefers specific color maps
Something like this yeah, did you get this from increasing the alpha on fill or?
I think that is perfect, thank you, and more resemblance and it might become plagiarism ๐
gl with your project ๐
thank you, you're a lifesaver! really needed that 2nd pair of eyes
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
publicly_available_medians_gdf = pd.read_csv("radardata.csv")
df = publicly_available_medians_gdf.set_index("5_attr_adj")
attrs = df.columns.tolist()
angles = np.linspace(0, 2 * np.pi, len(attrs), endpoint=False).tolist()
angles += angles[:1]
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
ax.set_theta_offset(np.pi / 2)
ax.set_theta_direction(-1)
viridis_frequently_used = plt.get_cmap("viridis", len(publicly_available_medians_gdf["5_attr_adj"].unique()))
colors = viridis_frequently_used(np.linspace(0, 1, len(df)))
for i, (_, row) in enumerate(df.iterrows()):
values = row.tolist()
values += values[:1]
ax.fill(angles, values, color=colors[i], alpha=0.3)
y_ticks = [0.2, 0.4, 0.6, 0.8, 1.0]
ax.set_yticks(y_ticks)
ax.set_yticklabels([str(y) for y in y_ticks], fontsize=10, color="gray")
ax.set_xticks(angles[:-1])
ax.set_xticklabels(attrs, fontsize=10)
ax.yaxis.grid(True)
plt.show()
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.