Skip to content

Tag: matplotlib

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 fro…

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 ope…

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 wo…

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 s…