data-visualization

Matplotlib 3D scatter plot animation not moving

Matplotlib 3D scatter plot animation not moving Question: I am a python beginner. This is my first time building a 3D scatterplot animation. In my code, I only want 6 points to display in a frame and remove points before the next frame comes. After writing the code, the problem came. The video is like …

Total answers: 1

matplotlib multiple groups with different scale

matplotlib multiple groups with different scale Question: I have the following script but the resulting plot for the second group is skewed by the first one. labels = [‘CA’, ‘ME’] Addmitted = [500000, 100] Applied = [10000000, 1000] x = np.arange(len(labels)) width = 0.35 fig, ax = plt.subplots() rects1 = ax.bar(x – width/2, Addmitted, width, …

Total answers: 1

How can I fix this matplotlib issue?

How can I fix this matplotlib issue? Question: import matplotlib.pyplot as plt import numpy as np x = np.array(["A", "B", "C", "D"]) y = np.array([3, 8, 1, 10]) plt.bar(x,y) plt.show() It doesn’t show me the diagram! Only this text: <BarContainer object of 4 artists> This code is simple, so as to be more comprehensive. I …

Total answers: 1

Better way to show duplicates in Pandas

Better way to show duplicates in Pandas Question: dups_df = df.pivot_table(columns=[‘DstAddr’], aggfunc=’size’) print (dups_df ) I am using this code block to show the duplicates but I would like to see the output in order(most used one) and maybe with a better visualization. How can I do this? Asked By: linuxpanther || Source Answers: you …

Total answers: 3

Plotly: Is it possible to color specific portion of the line in line chart?

Plotly: Is it possible to color specific portion of the line in line chart? Question: Sample line chart import plotly.express as px df = px.data.stocks() fig = px.line(df, x=’date’, y="GOOG") fig.show() I want to color the values > 1.1 and values<0.95 to a different color(ex: red) Is it possible in plotly to color the specific …

Total answers: 1

How to generate a choropleth map based on region names?

How to generate a choropleth map based on region names? Question: I’m working on Python with a dataset that has data about a numerical variable for each italian region, like this: import numpy as np import pandas as pd regions = [‘Trentino Alto Adige’, "Valle d’Aosta", ‘Veneto’, ‘Lombardia’, ‘Emilia-Romagna’, ‘Toscana’, ‘Friuli-Venezia Giulia’, ‘Liguria’, ‘Piemonte’, ‘Marche’, …

Total answers: 1

Setting titles on chart with different scales

Setting titles on chart with different scales Question: I am working with Matplotlib. Below you can see my data and plot. import pandas as pd import matplotlib.pyplot as plt from matplotlib.cm import get_cmap data = {‘year’: [2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023], …

Total answers: 1

Clustered Column Line with Mathplotlib

Clustered Column Line with Mathplotlib Question: I am trying to make a Clustered Column Line with Mathplotlib. Below you can see data import pandas as pd import numpy as np pd.set_option(‘max_columns’, None) import matplotlib.pyplot as plt data = { ‘year’:[2005,2006,2007,2008,2009,2010,2011,2012,2013,2014], ‘open’:[70,20,24,150,80,90,60,90,20,20], ‘closed’:[30,14,20,10,20,40,10,10,10,10], } df = pd.DataFrame(data, columns = [ ‘year’, ‘open’, ‘closed’, ]) Now I …

Total answers: 2

How to plot when columns are rows of dictionaries with a numpy array

How to plot columns of dictionaries containing a numpy array Question: I have a dataframe with a dict inside each cell that contains data like the pic attached, I want to plot column 1 and 2 (index order) to get something like this: n = len(df3) fig,ax = plt.subplots() for i in range(n): ax.plot([*df3[i][:,1].values()], [*df3[i][:,2].values()],label=df3[i][:,0]) …

Total answers: 1

How to add the percentage value along with the value count in Plotly Express Bar chart

How to add the percentage value along with the value count in Plotly Express Bar chart Question: Shown below is the syntax used to get the bar chart for a categorical data on plotly express df1= df[‘Catergory’].value_counts().reset_index(name=’Total’) df1[‘Percentage’] = round((df1[‘Total’] / df1[‘Total’].sum())* 100,0) fig = px.bar(df1, x=’index’, y=’values’, text_auto= False, text=df[‘Percentage’].apply(lambda x: ‘{0:1.1f}%’.format(x))) fig.update_traces(textfont_size=12, textangle=0, …

Total answers: 1