MCPcopy Create free account
hub / github.com/spotify/chartify / plot_radar_radius

Function plot_radar_radius

chartify/examples.py:1025–1063  ·  view source on GitHub ↗

Radar area example

()

Source from the content-addressed store, hash-verified

1023
1024@_print_source
1025def plot_radar_radius():
1026 """Radar area example"""
1027 import chartify
1028 from itertools import product
1029
1030 # Generate example data
1031 data = chartify.examples.example_data()
1032
1033 total_by_country = data.groupby(["country"])["quantity"].sum().reset_index()
1034 countries = total_by_country.country.unique()
1035 grid_values = product(range(0, 1200, 200), countries)
1036 grid_df = pd.DataFrame.from_records(grid_values, columns=["quantity", "country"])
1037 quantity_label = grid_df.groupby("quantity")[["quantity"]].min().reset_index(drop=True)
1038
1039 ch = chartify.RadarChart(True, layout="slide_50%")
1040 ch.set_title("Radar Radius Chart")
1041
1042 ch.style.set_color_palette("categorical", ["grey"])
1043 # Plot quantity labels
1044 ch.plot.text(
1045 quantity_label,
1046 "quantity",
1047 text_column="quantity",
1048 color_column="quantity",
1049 font_size="8pt",
1050 )
1051 # Plot perimeter grid
1052 ch.plot.perimeter(grid_df, radius_column="quantity", color_column="quantity", line_width=1)
1053 ch.style.set_color_palette("categorical")
1054
1055 # Plot text labels
1056 ch.plot.text(total_by_country, "quantity", text_column="country", text_align="center")
1057 ch.style.color_palette.reset_palette_order()
1058 # Plot the radius
1059 ch.plot.radius(total_by_country, "quantity")
1060 ch.axes.hide_yaxis()
1061 ch.axes.hide_xaxis()
1062 ch.set_legend_location(None)
1063 ch.show(_OUTPUT_FORMAT)
1064
1065
1066@_print_source

Callers

nothing calls this directly

Calls 10

set_titleMethod · 0.80
set_color_paletteMethod · 0.80
perimeterMethod · 0.80
reset_palette_orderMethod · 0.80
radiusMethod · 0.80
set_legend_locationMethod · 0.80
textMethod · 0.45
hide_yaxisMethod · 0.45
hide_xaxisMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected