Skip to content

Tag: matplotlib

How to efficiently draw a plot of a torch.nn model?

I’m exploring neural networks, and I want to model some pictures with neural network. Picture is a function that maps pixel coordinates to color, so I make my network also with 2 input variables (x, y) and 1 (shade) to 3 (R, G, B) output coordinates. For example, like this: Now, I plot it like this: But…

Making legend for subplot with scatter points

I’m trying to make a legend for my subplot using Python. Here’s part of my code: This method works when I was not using subplot, but now it returns me the following error message: I’m not pretty sure how I can fix this issue. Thanks for the help! Answer The code has an object which should no…

Total figure width with external legend in matplotlib

I’m using plt.legend(bbox_to_anchor = (1,1)) to put the legend outside my figure. The journal to which I’m submitting requires specific sizes for the figures. When I use this method, it increases the total width of my figure beyond the required size. I want to have the figure sized exactly to spec…

Reflecting 4d symmetric data

I’ve found out that there is no example of how to reflect symmetric 4d data, which can be very useful when 3d simulations wants to be performed using a symmetric plane to reduce calculations(e.g. ANSYS, COMSOL, etc). This example shows a data file structure corresponding to a COMSOL simulation, which ha…