I am struggling with plotting something, that I thought should be really simple. I have a dataframe/table df that contains the coordinates x,y,z of spheres. Additionally, in a separate column, it contains the radius of these spheres. How can I make with plotly a 3d plot of the spheres in space with their correct radius being used? The closest I
Tag: matplotlib
Order categories in a grouped bar in matplotlib
I am trying to plot a groupby-pandas-dataframe in which I have a categorical variable by which I would like to order the bars. A sample code of what I am doing: Which plots: However, I would like to plot within each category the order to be Jan, Feb, March. Any help on how to achieve this would be a appreciated.
how to format dates on x-axis in matplotlib?
I am trying to plot average temperatures from 1960 to 2021 for the month of December from time series data. my dataframe contains mean minimum and mean maximum temperatures, as for plotting i am trying as, for formatting dates on x-axis, i am trying as, but this gives me very messy x-axis ticks (all dates from 1960-2021), but i want
How to generate random values for a predefined function?
I have a predefined function, for example this: How can I generate random values against it so I can plot the results of the function using matplotlib? Answer If you want to plot, don’t use random x values but rather a range. Also you should use numpy.exp that can take a vector as input and your y in the lambda
How to order categorical month variable when plotting using matplotlib?
I am doing some topic modelling, and I am interested in showing how the average topic weight changes over time. The problem arises when I plot it using matplotlib (version 3.3.4). On the x-axis I would like to have the categorical month_year variable. The problem is that it is not ordered in a sensible way. I have tried, as suggested
Add trend line to datetime matplotlib line graph
I have a pandas dataframe df: And I can plot this easily using plt.plot: But now I want to add a trendline. I tried using some answers: How can I draw scatter trend line on matplot? Python-Pandas Which doesn’t work: Then I found the following question and answer: TypeError: ufunc subtract cannot use operands with types dtype(‘<M8[ns]’) and dtype(‘float64’) But
Fill color in single cells in a networkx graph
I’ve build a graph with networkx, that looks like this: Graph I want to fill every singel cell with a specified color. The Graph was drawn by nx.draw_networkx_edges() (returns a LineCollection). I found a similar question here (Fill area between lines), but the solution in the comments, doesn’t worked for me. I’ve also used plt.fill_between with a simpler graph and
How do I rearrange the order of pie slices in pandas plot?
I am trying to rearrange the order of the pie slices in my pie chart. I am relatively new to Python and am having trouble figuring this out. Here is my current code: The pie chart slices arrange in alphabetical order by the names of the countries, even though my dataframe is different. So, how do I change the order
Axis labels are cut off when using subplot with just one plot
I have plot with axis labels looking like this created by this code: If I resize the master object of the plot (in this case the window) to smaller size, the axes labels are cut off like so and but if I create the subplot with two plots (the second one doesn’t have to be populated with a plot), the
Create automatic tick labels for a tkinter scale
I want to create a scale with tick labels that are automatically chosen so they fit on to the scale without interfering with each other. Here is an example code for crating one that resizes with the window: When creating a plot with matplotlib, this happens by default and even gets updated when changing the size of the plot window.