Author Archive

Sketch based app for Charts

January 26th, 2016 No comments

This is a prototype for simple creation and manipulation of charts. The system recognizes 12 different chart types. By using a stochastic approach it decides to the highest probability based on the sketch which graph to render. A set of gestures is also defined once a graph is rendered. The gestures action will depend on the nature of the graph, e.g., a ‘x’ will delete a bar in a bar chart, a slice in a pie chart or a point in a line chart.

Categories: charts, strokes Tags:

Optimal final_third policy in Robocup 2D using HyperNEAT

December 9th, 2015 No comments

Final project of the Neuroevolution and Generative and Developmental Systems class ( Inspired on this paper a new policy was developed to instead of players keep the ball, players learn to score. Even though we run just 30 generations which is considered low, the best individual performed better than taking random decisions and better than a scripted behavior as can be seen not probably in the video but on the statistics gathered.

Create user for ssh access to aws ec2 instance

September 28th, 2015 No comments

Creating a user in an amazon ec2 instance in my case ubuntu:

sudo adduser <new_user>
# Next step gives access level
sudo adduser <new_user> sudo 

Create the folder .ssh for the user just created:

cd /home/<new_user>
mkdir .ssh

On your local computer:

    • Generate a key using strong encription:
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -C "optional comment about key"
    • Then check that .ssh directory and the files have right permissions:
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
    • Next, upload the public key to your server:
cat ~/.ssh/ | ssh ubuntu@<public_ip> 'cat - >> ~/.ssh/authorized_keys'

In the remote server:

    • Copy the authorized_keys from the ubuntu user to the newly created .ssh folder of the new user.
cp ~/.ssh/authorized_keys /home/<new_user>/.ssh/
    • Change the owner of the folder and files to the user newly created:
sudo chown <new_user>:<new_user> /home/<new_user>/.ssh/
sudo chown <new_user>:<new_user> /home/<new_user>/.ssh/authorized_keys
    • Finally login as the user you just created and ensure that the .ssh folder and authorized_keys have the right permissions.
chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh/

At this point you should be able to login using the default amazon key to both users. But in order to login from your computer with the key and the you just created, it is necessary to remove the from your local .ssh/ folder.
In the authorized_keys from the you would need to remove the first entry so the can not login using the amazon default initial key.

Categories: aws, ec2 Tags: , ,

ggplot for python calling kivy matplotlib backend

September 1st, 2015 No comments

Based on the grammar of graphics, ggplot is a library for plotting graphs in R. By doing some readings seems like ggplot is a very good choice to produce multi-layered graphs. I found a package for python which provides a ggplot structure wrapped into matplotlib instructions. I gave it a try by installing it from source and then, since the library is heavily depending on matplotlib I changed the backend by default to use kivy by placing these two lines on top of each example tested:

import matplotlib

The main advantage in my case is the minimum set of instructions required for creating plots. Some resources can be found here I have not fully tested it but I am giving it a try. ggplot

Matplotlib backend kivy in Windows hands on

September 1st, 2015 7 comments

The backend implementations for matplotlib in kivy work just with kivy versions greater or equal than 1.9.1. It is required to install kivy in development mode following these steps: After step 10 you can additionally run

python install

The script kivy.bat creates an environment in which some python tools are ready to use, for instance pip. The next step is to download numpy and matplotlib from this binaries repositories: and Once downloaded install both using pip and then install kivy-garden and the matplotlib package for kivy.

pip install "numpy-1.10.0b1+mkl-cp27-none-win32.whl"
pip install "matplotlib-1.4.3-cp27-none-win32.whl"
pip install kivy-garden
garden install matplotlib

You can go now to the folder that by default garden packages are installed. In my case C:\Users\my_user\.kivy\garden\

cd garden.matplotlib/examples

And you should be able to see the matplotlib widget working on windows. Follow the steps from to create a shortcut to execute your kivy apps.

Now you can go directly to the garden path using a file explorer, do right click on and send to kivy-2.7.bat which will start the application.

Categories: kivy, matplotlib Tags: , ,

Matplotlib for Kivy Final Notes

August 26th, 2015 No comments

As outcome of one of the projects from the google summer of code 2015 two packages were created and are available as kivy garden packages.

These two packages can be used separately or can be combined as shown in


– If you are using dash_list attribute when creating a line in a figure, it will not work until the update is done in the next kivy version.
– The backend only works with the kivy >= 1.9.1. Some changes were done in the Widget class.
– Matplotlib backend has not been tested on android.

Both packages have been tested and debugged, however it is highly encouraged to submit any issue found while using them. Some of its advantages and weaknesses are exposed in the following paragraphs:

The first package is garden.matplotlib which is a matplotlib backend for kivy, it allows to create applications using pyplot instructions or to embed figures into a kivy application. There are two possible backends that can be invoked:

– backend_kivy which does the render using kivy graphics instructions.
– backend_kivyagg which does the render using an static image texture.

Both of the backends can be connected to the default matplotlib events Additionally another widget called NavigationToolbar can be instantiated and used with both backends, a better description can be found in A FigureCanvas can be used without a NavigationToolbar but a NavigationToolbar needs a FigureCanvas to be instantiated. The main advantage of this package is the ability to be added as another Kivy widget inside a Kivy application through the use of matplotlib instructions.

There are some features that were not implemented and the users should be aware of:

– backend_kivy and backend_kivyagg are non interactive backends (
– gouraud shading in backend_kivy
– configure_subplots button in the NavigationToolbar is not implemented.

Known bugs:

– When zooming on an area with not enough graphics instructions the render is not properly done.

In the same way there are some features implemented in backend_kivy that are not implemented in other graphics instructions based backends.

– clip path when rendering an image.
– draw_path_collection method for optimization.
– draw_markers for optimization.

We believe most of matplotlib current capabilities have been considered during this backend implementation. However, we encourage to submit any capability missed you may find.

Categories: GSOC2015, kivy, matplotlib Tags: , ,

N$ recognizer kivy implementation

August 18th, 2015 No comments
Categories: GSOC2015, kivy, python Tags: , , ,

Corner detection on Strokes and Strokes annotations on Matplotlib

August 6th, 2015 2 comments

Following my proposal for the Google Summer of Code 2015, an algorithm to detect corners on strokes was implemented and it is going to be polished and tested with a template matching classifier. This implementation follows Wolin approach in his paper: “ShortStraw: A Simple and Effective Corner Finder for Polylines” which can be downloaded from:

A brief explanation of the algorithm consists on sampling each one of the points in order to have equal distance between them. Then a window of +/-3 points is used and the average or mean of the distances is calculated. The distance between the initial point and the last point of the window form a straw. The straw is smaller in the cases that the window of points contain a corner.

corners strokesFrom the figure can be seen that pretty much corners are being detected. However a post processing still needs to be performed. In addition, a stroke canvas behavior was added to a figure canvas widget so annotations can be done on top of the graphs as can be seen in the figure below. The yellow background and the blue dots are just debugging information.

backend_kivy with annotations

backend_kivy and backend_kivyagg working with matplotlib 1.4.3, python2 and python3.

August 6th, 2015 No comments

Initially backend_kivy was implemented using matplotlib 1.5.1dev which is an unstable release. Small modifications were made based on the changes matplotlib has between 1.4.3 (stable) and 1.5.1dev. Some of the main points that were updated were the generation of MathText and the lines rendering in draw_path. Additionally in the case of backend_kivyagg a read-only memory view was sent from the agg renderer to the kivy backend, a writable copy had to be created due to an exception in cython for loading read-only buffers. Some other improvements involve a bug when the application was being closed which was fixed by adding an on_close event in the app and setting the global var app to None, another improvement is the generation of images from the plots. In the case of backend_kivy the figure canvas widget is being exported to png using the export_to_png(filename). A bug was reported when the FigureCanvasKivy is added to a BorderLayout and the window is resized. For instance if we have a button on top of the figure canvas, when resized the figure canvas is resized to the size of the window moving the button up but then is scaled down again and the dimensions are right. This arises in the backend_kivy due to a small delay that keeps the calculation of the positions in this case of the button out of the canvas. In backend_kivyagg this does not happen due to a fast transition so the button position is calculated correctly. (still an open issue and working on that for backend_kivy.)

Navigation Toolbar with matplotlib events connected

August 6th, 2015 No comments

NavigationToolbar is the last visual aspect from the backend that has been added with all the possible events connected to matplotlib. The main changes performed on the implementation involved to connect each one of the toolbar elements to the respective matplotlib calls. Additionally, the figure canvas is separated from the toolbar and both are children of a Float Layout inside an app generated via pyplot. The FigureCanvasKivy can be called independently of the NavigationToolbar but not in the opposite direction.

# updated version of the toolbar generation.
def _init_toolbar(self):
        basedir = os.path.join(rcParams['datapath'], 'images')
        actionview = ActionView()
        actionprevious = ActionPrevious(title="Navigation", with_previous=False)
        actionoverflow = ActionOverflow()
        actionview.use_separator = True
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
            fname = os.path.join(basedir, image_file + '.png')
            if text in ['Pan', 'Zoom']:
                action_button = ActionToggleButton(text=text, icon=fname)
                action_button = ActionButton(text=text, icon=fname)
            action_button.bind(on_press=getattr(self, callback))

Navigation Toolbar Kivy

For matplotlib users the interface can look very familiar. However, I consider a brief explanation is necessary on the function of each button:

Home: Resets the plot axes to the initial state.
Left: Undo an operation performed.
Right: Redo an operation performed.
Pan: Allows to drag the plot.
Zoom: Allows to define a rectangular area to zoom in.
Configure: Not implemented yet but, loads a pop up for repositioning elements.
Save: Loads a Save Dialog to generate an image.
Configure and Save will be added at some point the next week.

Categories: GSOC2015, kivy, matplotlib Tags: , ,