Created
January 18, 2022 02:52
-
-
Save Hehehe421/f32efee1522bf83cef5624ce090bd748 to your computer and use it in GitHub Desktop.
Medium - Radar Chart - Syntax 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This code helps you create two make up customers moive genre profile on separated radar charts in python*/ | |
from plotly.subplots import make_subplots | |
import plotly.graph_objects as go | |
import plotly.offline as pyo | |
genre = ['Action', 'Comedy', 'Drama', 'Horror', 'Mystery', 'Romance'] | |
c_1 = [22, 98, 8, 109, 111, 29] | |
c_2 = [49, 67, 140, 13, 24] | |
def customer_profile_data(result_name): | |
fig = make_subplots( | |
rows = 1, cols = 2, | |
specs = [[{"type": "scatterpolar"}, {"type": "scatterpolar"}]], | |
subplot_titles = ("Customer 1", "Customer 2")) | |
fig.add_trace(go.Scatterpolar( | |
r = c_1, | |
theta = genre, | |
fill = 'toself', | |
name = 'Customer 1'), row = 1, col = 1) | |
fig.add_trace(go.Scatterpolar( | |
r = c_2, | |
theta = genre, | |
fill = 'toself', | |
name = 'Customer 2'), row = 1, col = 2) | |
fig.update_layout(showlegend = False, title_text = "Customer Profile") | |
for annotation in fig['layout']['annotations']: | |
annotation['yanchor'] = 'bottom' | |
annotation['y'] = 1.1 | |
annotation['yref'] = 'paper' | |
plot(fig, show_link = True, filename = 'customer_profile_'+result_name+'.html') | |
customer_profile_data(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment