I have a dataframe similar to the following import pandas as pd import matplotlib.pyplot as plt df = pd.DataFrame({ ‘make’: [‘Audi’, ‘BMW’, ‘Ford’, ‘Nissan’, ‘Ford’], ‘price’: [350000, 489000,…
Tag: matplotlib
View Alaskan/East Siberian Side of Arctic in Cartopy
I have some points plotted on a NorthPolarStero map in Cartopy using the following code But I would actually like to plot just the top half of this image, like this: If I change the “`ax.set_extent“ line to either: [90, -90, 90, 66] or [-90, 90, 90, 66] It just gives me the bottom half of the plot, like this:
Get pandas boxplot in one plot and matplotlib plot in another figure
When I run the program, the two plots are plotted in one figure, but I want them in two separate figures. Answer The pandas.DataFrame.boxplot takes an ax parameter, as written in the docs. So you can use: Otherwise, you can plot in different subplots of the same figure by applying minimal changes.
I get a double decade when plot semi-log x-axis : how to force display each decade?
I am faced with a simple problem. When I do a semi-log plot(log on x-axis) like this : Then, I get the following figure : As you can see, I have double decades on x-axis: how to force matplotlib to draw each decade and not passing for example from 10^1 directly to 10^3? And finally, how to make appear the
Pyplot start x axis at negative values
I am trying to plot a piecewise function, but at the moment I am getting an error message when I try to start my x values at a negative. The code works fine if I run the following (albeit with only one part of the function): But when I change the first line to I get thrown the error message:
Why is ‘figure’ object not callable in nested function?
I’m calling a function that creates a matplotlib figure with two subplots and then plots subplots with nested functions. It looks like this basically: When I call, this I get this type error: ‘Figure’ object is not callable. I’ve done this kind of thing in other contexts before, so I’m curious what potential causes are, or what exactly this error
How do you switch the colors of a bar chart in python matplotlib?
I’m trying to switch the colors of my bar charts so that they’re consistent throughout. In the plots below, I want to make it so JP_Sales is orange in both charts and NA_Sales is blue in both charts. The code for the first chart is: The code for the second chart is: Answer plot() has a color argument which takes
Matplotlib Contourf with Irregular Data
I have a soil property data with depth in different x points. The borehole data are not in equal depth or number, so I have to standardize the code. If all boreholes have same number of data and depth, no problem, np.meshgrid will work fine. However, in my case, I had a trouble and couldn’t manage to draw a contourf
Matplotlib plot with ConnectionPaths objects layout issues
I have a script that plots point correspondences between images: This results with an overlap of the axes ticks of one image with the other. When I try to add fig.tight_layout() at the end of the script the image’s size is drastically diminished: Is it possible to keep the images large and avoid the ticks overlapping? Thanks! Answer As mentioned
Is there any way to show mean in box plot using Python?
I’m just starting using Matplotlib, and I’m trying to learn how to draw a box plot in Python using Colab. My problem is: I’m not able to put the median on the graph. The graph just showed the quartiles, mean, and outliers. Can someone help me? My code is the following. Answer I tried running your code with a sample