Given the following: This will create 2 separate plots. How can I add the data from df2 onto the SAME graph? All the seaborn examples I have found online seem to focus on how you can create adjacent graphs (say, via the ‘hue’ and ‘col_wrap’ options). Also, I prefer not to use the dataset examples where an additional column might
Tag: matplotlib
‘numpy.ndarray’ object has no attribute ‘find’ while trying to generate boxplot?
I am trying to generate a box plot. Here is my code, data below: The data is float which is verified by the print command as its output is <type ‘float’>. On running the code, I am getting the following error (full stacktrace below) AttributeError: ‘numpy.ndarray’ object has no attribute ‘find’ My data (e.g. in dataset1) looks like this output
Matplotlib – adding subplots to a subplot?
I’m trying to create a figure that consists of a 2×2 grid, where in each quadrant there are 2 vertically stacked subplots (i.e. a 2×1 grid). I can’t seem to figure out how to achieve this, though. The closest I’ve gotten is using gridspec and some ugly code (see below), but because gridspec.update(hspace=X) changes the spacing for all of the
Python Scatter Plot with Multiple Y values for each X
I am trying to use Python to create a scatter plot that contains two X categories “cat1” “cat2” and each category has multiple Y values. I can get this to work if the number of Y values for each X value is the same by using this following code: but as soon as the number of Y values for each
How can I remove digits after decimal in axis ticks in matplotlib?
I have This (and some additional code) produces the following plot, but I’d like to remove the decimal point and the digit after it from the tick labels on the top x axis. Using matplotlib.ticker.FormatStrFormatter(fmt) does not help Answer Convert the numbers into ints:
Arrow on a line plot with matplotlib
I’d like to add an arrow to a line plot with matplotlib like in the plot below (drawn with pgfplots). How can I do (position and direction of the arrow should be parameters ideally)? Here is some code to experiment. Thanks. Answer In my experience this works best by using annotate. Thereby you avoid the weird warping you get with
Histogram with Boxplot above in Python
Hi I wanted to draw a histogram with a boxplot appearing the top of the histogram showing the Q1,Q2 and Q3 as well as the outliers. Example phone is below. (I am using Python and Pandas) I have checked several examples using matplotlib.pyplot but hardly came out with a good example. And I also wanted to have the histogram curve
How to create groupby subplots in Pandas?
I’ve got a dataframe with timeseries data of crime with a facet on offence (which looks like the format below). What I’d like to perform a groupby plot on the dataframe so that it’s possible to explore trends in crime over time. I’ve got some code which does the job, but it’s a bit clumsy and it loses the time
Plotting a NACA 4-series airfoil
I’m trying to plot an airfoil from the formula as described on this wikipedia page. This Jupyter notebook can be viewed on this github page. The result looks like . I expected it to look more like . Questions: Why is the line not completely smooth? There seems to be a discontinuity where the beginning and end meet. Why does
How to change the figure size of a seaborn axes or figure level plot
How do I change the size of my image so it’s suitable for printing? For example, I’d like to use to A4 paper, whose dimensions are 11.7 inches by 8.27 inches in landscape orientation. Answer You need to create the matplotlib Figure and Axes objects ahead of time, specifying how big the figure is: