combining gnuplot with a gui in haskell - haskell

Can any one provide an example , or advice as to what would be the best approach for using gnu-plot or something similar from within a Haskell GUI?

the Chart package and the plot package both use cairo as a 2D renderer which can be used with GTK.
The plot-gtk package provides a custom widget to display plots in GTK. plot can plot functions or data series which are Data.Vector.Storable from the vector package and thus are compatible with hmatrix and friends.
There is an example in the plot package in Graphics.Rendering.Plot

Related

How to use the same kde used by seaborn

I'm trying to use kernel density estimator to obtain the distribution of my data. Using the seaborn, I can simply call sns.kdeplot(temp, shade=True) and that will plot the kde or the distribution of my data. However, with seaborn, I cannot obtain scores for new data points. However, if I'm using the sklearn library, I can simply call kde.score_samples(data). Therefore, how can I achieve the same thing with seaborn? Or, is there a way I can return the kde obtained from seaborn?
Any help is much appreciated!
After looking through the documentation https://github.com/mwaskom/seaborn/blob/a9577e705023873de7c7bbf3e9b6ae0dc1880b51/seaborn/distributions.py#L2641, the bandwidth of the kernel is calculated as: bw = stats.gaussian_kde(a).scotts_factor() * a.std(ddof=1) Consequently, I've used the bw with kde from sklearn as: kde = KernelDensity(kernel='gaussian', bandwidth=bw).fit(temp.reshape(-1, 1)).
Thus, now I'm able to call: kde.score_samples(x_axis.reshape(-1, 1)).

Any function in Gnuplot that is equivalent of the Beeswarm dotplot?

I am looking for a function in Gnuplot to create a so called Beeswarm dotplot. This is very popular plots used in medicine and biology. I know it can be done in Grapgpad Prism and in R but I would like to continue using Gnuplots for making graphs

Haskell equivilant of numpy's imshow

In numpy, it is possible to visualize an array of numeric values by using imshow. I wish to produce similar images in Haskell, including displaying axes, titles, and so on. Additionally, it would be useful if it were possible to overlay e.g. geometric shapes on top of the visualized array.
I see many libraries that might already implement this kind of functionality, but can't find it myself. If it does not exist, where would be my best bet to start ?
The answers to this SO question contain some suggestions and code examples:
Which haskell library will let me save a 2D array/vector to a png/jpg/gif… file?
imshow doesn't come from numpy, it comes from matplotlib. matplotlib is a native Python library, so to use it in a Haskell program you'd need to get to it through the Python c API. There's already a library of Haskell bindings to the Python c API, cpython. This would probably be a bit tricky to use because it can't marshall functions, and, although I'm not familiar with matplotlib, plotting libraries typically take functions for features such as tick and label formatting.
From the plot package
ms :: Matrix Double
ms = buildMatrix 64 64 (\(x,y) -> sin (2*2*pi*(fromIntegral x)/64) * cos (5*2*pi (fromIntegral y)/64))
mat_fig = do
setPlots 1 1
withPlot (1,1) $ do
setDataset ms
addAxis XAxis (Side Lower) $ setTickLabelFormat "%.0f"
addAxis YAxis (Side Lower) $ setTickLabelFormat "%.0f"
setRangeFromData XAxis Lower Linear
setRangeFromData YAxis Lower Linear
You can also add title and subtitle and you can use annotations to draw arbitrary shapes on the plot area.

How can I draw an implicit function f(x,y,z)=0 with gnuplot?

I want to draw the following implicit function with gnuplot
x**2+y**2+(z-1)**3-2
I know that maple or matlab can to this very simple but I want to use gnuplot.
Up to know I have no idea so I can't provide a starting point.
sorry
Here the result plotted with maple
According to the Gnuplot FAQ, this is not directly possible. There is a workaround for 2D-functions, but I don't see how this method can be applied to 3D graphs. I'd recommend solving the equation in Octave or some similar program and outputting the solutions to a file, which you can then feed into GnuPlot.

2d geometry drawing tool

I'm looking for some tool/library that is able to draw simple 2d geometries from text file or programatically. I already found List of interactive geometry software but that not quite what I'm looking for. I would prefer something more similar in usage to graphviz or gnuplot. I already wrote some scripts for gnuplot but this tool has been designed for different purposes. Required functionality:
support for different kind of 2D geometries: points, segments, lines, circles, polygons
simple input type format maybe similar to postgis Well Known Text
support for objects additional data like tags and colors definition
output in common image format or some kind of interactive GUI (with zoom in/out and select object)
configurable grid
autoscale or draw in defined area
I will use it for testing geometry algorithms and don't want to reinvent the wheel.
Matplotlib. I'm not familiar with all the aspects of this Python library but I've heard it is pretty good.
To quote their introduction,
matplotlib is a python 2D plotting
library which produces publication
quality figures in a variety of
hardcopy formats and interactive
environments across platforms.
matplotlib can be used in python
scripts, the python and ipython shell
(ala MATLAB®* or Mathematica®†), web
application servers, and six graphical
user interface toolkits.
matplotlib tries to make easy things
easy and hard things possible. You can
generate plots, histograms, power
spectra, bar charts, errorcharts,
scatterplots, etc, with just a few
lines of code. For a sampling, see the
screenshots, thumbnail gallery, and
examples directory
(source: sourceforge.net)
>
For example, using "ipython -pylab" to
provide an interactive environment, to
generate 10,000 gaussian random
numbers and plot a histogram with 100
bins, you simply need to type
x = randn(10000)
hist(x, 100)
For the power user, you have full
control of line styles, font
properties, axes properties, etc, via
an object oriented interface or via a
set of functions familiar to MATLAB
users. The pylab mode provides all of
the pyplot plotting functions listed
below, as well as non-plotting
functions from numpy and
matplotlib.mlab.
Maybe dia, with it's SVG output option is what you're looking for? It can be scripted in Python.

Resources