Skip to content

Tag: matplotlib

How to resize x axis

I want to resize the x-axis range, but I don’t know how to do that. The range I want to resize is [under 20, under 40, under 60, under 80]. X represent age and Y represent survived rate Answer Put your data into age groups before plotting: If you want more polished labels:

How to plot DENDROGRAM in GUI

I am using a GUI from QtDesigner to plot Dendrogram. My code is below, but I can not plot the Dendrogram, how can I fix it? Image of Dendrogram: Answer You have to import the dendrogram from scipy: And then pass it the axes through the ax argument:

Removing Lines from Contourf in Matplotlib

I am using the following code to contour plot some data using contourf in matplotlib. I have set the transparency of the colourbar to 0.6, but there are annoying lines between each colour interval that I cant get rid of. There doesnt seem to be a way to set linestyle in contourf, any ideas? Answer You can add…

How to create a multi-colored curve in 3d?

I’m trying to plot a 3d curve that has different colors depending on one of its parameters. I tried this method similar to this question, but it doesn’t work. Can anyone point me in the right direction? Answer To extend the approach in this tutorial to 3D, use x,y,z instead of x,y. The desired sha…

Why Matplotlib.hist taking different list?

I’m trying to plot the following And getting This one actually draws a different array([ 1., 4., 5., 8., 9., 10., 10., 10., 10., 10.], which is created run time automatically. Answer I assume you mean the red histogram appears to be wrong? It’s not. You’ve got cumulative=True so it adds each…