I have a text file, with the coordinates of two circles on it. I want to produce a live animation of both particles. For some reason the following code crashes The text file that the data is taken from has the columns of X1, Y1, X2 and Y2 where X1 represents the x coordinate of the 1st particle etc. If
Tag: matplotlib
How do I overlay multiple sns distplots or change the colour based on a secondary variable using a pandas df
I have a pandas dataframe with a ‘frequency_mhz’ variable and a ‘type’ variable. I want to create a dist plot using seaborne that overlays all of the frequencys but changes the colour based on the ‘type’. Is there a way I can overlay the 3 into one plot? or a way ive missed to change the colour of the bars
How to make sns.jointplot histogram into a smooth kde?
I’m plotting some data using sns.jointplot and I want the data inside the scatterplot to remain as points and the histograms on the side to be kde plots instead. I’ve tried using the kind=’kde’ argument, but this changes the data inside to not look like points in a scatterplot anymore. I’ve searched around for a bit and can’t find how.
Returning plt.show() on HTML with Python Flask
I’m using Python Flask to take input from a simple html file. The HTML asks the user to input a state and when they do that I would like for the output to be a plot. I have the following code that’s creating the Python Flask but when a user inputs a state, the plot outputs in my Jupyter Notebook
How to loop through lists to create multiple plots Python
I have the following three lists: I was wondering how I can take these 3 lists and iterate through them to get lists so the first plot would be plotting dog as title with y value as the first list in 2d list 2 and the x value would the first list in 2d list 3. This would iterate for
How to make just one marker as hollow in matplotlib plot?
I have the following code: I tried the above and got the following error- How do I resolve this ? or is there an alternative solution to the problem ( rather than splitting into multiple figures)? Answer If you read the documentation associated to plt.plot, if you will see that the only properties affecting markers are: By looking at them,
Images constructed from dataset rotated
I am not very experienced with python plotting. I want to work with YaleB_32x32 dataset (https://github.com/flatironinstitute/online_psp/blob/master/datasets/YaleB_32x32.mat). This is my code : This is the output. As you can see that images are rotated. Could someone please help me with where am I going wrong? Answer You can use rot90 to rotate faces with numpy lib. Use axes=(1, 0) to rotate
How to change the default backend in matplotlib from ‘QtAgg’ to ‘Qt5Agg’ in Pycharm?
Qt5Agg is necessary to use the mayavi 3D visualization package. I have installed PyQt5 and mayavi using pip in a separate copied conda environment. The default backend then changes from TkAgg to QtAgg. This is a bit weird because in an earlier installation in a different PC the default changed directly to Qt5Agg. I always check the backend using the
How to add colorbar to existing axis handle?
This way is easy and works: But when it’s like this: How do I get the colorbar on that axis? I don’t need anything fancy, just the defaults. Answer Pass the respective image and axes handles into fig.colorbar:
Superscripting a string in python
Hello I am trying to superscript a string for a plot. And the result i get is: The “-0,2*x” should be superscripted. What am I doing wrong? Thank you! Answer It IS making the – a superscript. To get the whole expression in there, you need to enclose the whole expression in curly braces. Since you have this in an