I use corner package to plot contours. But the output figure is not smooth and it has a basic shape and step form:
Here is the code
import corner
fig = corner.corner(samples, labels=["$m$", "$b$", "$\ln\,f$"])
fig.show()
Is there any way to use this package and plot smooth graphs? Similar to this one or this one
I appreciate your help and your attention
You can use the smooth keyword (see documentation for more details) in corner.corner() to smoothen the posterior contours. Implementing it is as simple as setting smooth=True.
You could use seaborn to plot these smooth histograms. These smoothed histograms are called kernel density estimations. You can find some examples here, here for 2D and here. And here is an example which kinda looks like what you are trying to achieve.
Related
I am implementing the Fastdtw algorithm to find the optimal path to align two time-series data. I hope to output a plot like this:
However, I've never tried such kind of plot before. I guess maybe I need to use the imshow() function in matplotlib, but I don't know how to draw the extra trajectory in the plot.
I wish somebody coould give a similar example about drawing like such style. I will modify the parameters by myself.
I wonder if there is a way to draw a border around data points of the same cluster (same label) in a scatter plot, using Matplotlib? I mean borders, like in the attached image.
The keyword I was searching for was Convex Hulls. Scipy offers a class that can easily calculate the Convex Hull of a list of data points.
The code in this post was quite helpful: Plotting a set of given points to form a closed curve in matplotlib
What would be a good way to draw a figure such as the one shown in Figure 1 of the following paper:
here
It seems to be plotted with python, using matplotlib. But, maybe a tensorflow library or similar has been used, which I don't know.
Maybe try a hexbin plot from matplotlib.
I have a dataset of wind directions and I am looking to create raw data plots as seen in the example below. I should mention that I know about rose diagrams and how to create them in Python. This is another way of looking at the data and is commonly brought up in texts about directional statistics.
The plot is similar to a polar histogram, in that raw data is collected into continuous bins. But there are stacked individual dots for each data point instead of a bar.
I have found a solution on the mathematica stackexchange, but I have no experience with that language: circular plot and circular histogram. The book I took the above image from also gives the R code for it, but I only know Python.
Below is the minimal code I have until now.
directions = np.random.randint(low=0, high=90, size=50)
# Setup plot
ax = plt.subplot(111, polar=True)
ax.set_theta_zero_location("N")
ax.grid(False)
plt.show()
As you can see I have not made much progress. Again, I can find code for polar bar plots and histograms, but not for this type of plot in Python. Any hints in the right directions are welcome.
I have some data made of coordinates and the count of each coordinate which I plot in a heatmap like this:
pyplot.subplot(211)
pyplot.scatter(longitudes, latitudes, c=counts)
pyplot.colorbar()
which is inspired by this great answer here in SO.
If you look closely you can see, that the dots shape the worldmap somehow. To underline this effect I'd like to put the real country boarders (simply drawn would be enough) as background to my plot. Is this possible with matplotlib? Maybe there is some (hidden) builtin in matplotlib?
You can likely achieve this if you have some image of the world map that you want as a background. You can read this into a numpy array and plot the image. Then you should be able to add your scatter plot overtop of the image. This matplotlib cookbook example shows how to insert images and such. There is also the matplotlib image tutorial that may be of use.
I've not used it, but you may also be interested in the basemap toolkit for matplotlib. In particular, the section on drawing a map background mentions specifically a drawcountries() method.