figure

X and Y-axises is duplicated when major_formatter is set

X and Y-axises is duplicated when major_formatter is set Question: I have a code to plot an empty graph: from datetime import datetime, timedelta from matplotlib import pyplot, dates pyplot.yticks([0,1,2,3,4]) ts_start = datetime.now() – timedelta(hours=1) ts_end = datetime.now() delta = timedelta(minutes=10) x_dates = dates.drange(ts_start, ts_end, delta=delta) pyplot.xlim(x_dates[0], x_dates[-1]) # fmt = dates.DateFormatter(‘%Y-%m-%d %H:%M:%S’) # pyplot.axes().xaxis.set_major_formatter(fmt) …

Total answers: 1

Emulating Matlab Mesh Plot in Matplotlib yielding shadow effects

Emulating Matlab Mesh Plot in Matplotlib yielding shadow effects Question: I have this meshplot that looks very clean in matlab for a 3d surface (Ignore the red border line): And I am trying to emulate the same image in matplotlib. However, I get this weird shadow effect where the top of the surface is pure …

Total answers: 2

How to add names to dropdown menu in Plotly

How to add names to dropdown menu in Plotly Question: I’m not so good at python and also very new to plotly. I’m having a trouble adding labels(names) next to dropdown menus in Plotly figure. I managed to build an interactive table in which you can filter the data by columns having a quick research …

Total answers: 1

How to place the suptitle rotated on the side of the figure in Matplotlib

How to place the suptitle rotated on the side of the figure Question: I’m working with Matplotlib in Python, and have the simple figure-suptitle layout shown below Title ———- |Figure | |Pieces | ———- The figure pieces are squished a bit, however. To make room, I would like to put the figure suptitle on the …

Total answers: 1

Trying to change line thickness with matplotlib.mpatches.Patch

Trying to change line thickness with matplotlib.mpatches.Patch Question: I am manually making a legend as there are too many inputs in my figure, so I use matplotlib.mpatches.Patch to make legend using: orange_patch = mpatches.Patch(color=’orange’, label=’n=505 distribution’, lw = 1) grey_patch = mpatches.Patch(color = ‘grey’, label = ‘n=100 sampled 100 times’, lw = 1) plt.legend(handles=[orange_patch, grey_patch], …

Total answers: 1

Figure.show works only for figures managed by pyplot

Figure.show works only for figures managed by pyplot Question: There’s bug reported about using matplotlib.pyplot for matplotlib 3.5.1, so I am trying to use matplotlib.figure.Figure to draw figure and it work fine. How can I view the graph in matplotlib for the Figure when I cannot call plt.show? Calling fig.show will give the following exception: …

Total answers: 3

Adding a figure created in a function to another figure's subplot

Adding a figure created in a function to another figure's subplot Question: I created two functions that make two specific plots and returns me the respective figures: import matplotlib.pyplot as plt x = range(1,100) y = range(1,100) def my_plot_1(x,y): fig = plt.plot(x,y) return fig def my_plot_2(x,y): fig = plt.plot(x,y) return fig Now, outside of my …

Total answers: 1

Matplotlib Savefig will NOT overwrite old files

Matplotlib Savefig will NOT overwrite old files Question: This seems like it must be a permissions issue on my machine. After a systems update on Windows 10, when I run: import matplotlib.pyplot as plt #make figure plt.plot([1,2,3,4]) plt.ylabel(‘some numbers’) #save plt.savefig(“./figs/my_plot.jpg”) It will create the figure the first time the code is run. If I …

Total answers: 3

What are the differences between add_axes and add_subplot?

What are the differences between add_axes and add_subplot? Question: In a previous answer it was recommended to me to use add_subplot instead of add_axes to show axes correctly, but searching the documentation I couldn’t understand when and why I should use either one of these functions. Can anyone explain the differences? Asked By: Ivan || …

Total answers: 2