Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
nicoguaro / image_poster.py
Created Jan 9, 2020
Posterization of an image using k-means
View image_poster.py
"""
Posterization of an image using k-means
It can be used to create color palettes from pictures.
@author:Nicolás Guarín-Zapata
@date: January 2020
"""
import numpy as np
from scipy import misc
@nicoguaro
nicoguaro / inflacion_vs_derechos-log.png
Last active Nov 28, 2019
Correlacion entre "inflación" y "número de derechos" a partir de los datos presentados en el siguiente Tweet: https://mobile.twitter.com/clarroulet/status/730931861384507392
@nicoguaro
nicoguaro / polynote.yml
Last active Oct 25, 2019
Pre-configured conda environments
View polynote.yml
# Environment for polynote
#
#
name: polynote
channels:
- default
dependencies:
- python>=3.6
- pip
- jedi
@nicoguaro
nicoguaro / hello_anim.py
Last active Sep 12, 2019
Examples of plots in Matplotlib
View hello_anim.py
"""
Hello world (of animation)!
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
def update(data):
line.set_ydata(data)
@nicoguaro
nicoguaro / plot_inset_rect.py
Created Jun 12, 2019
Plot with an inset and a background color for the inset
View plot_inset_rect.py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
x = np.linspace(0, 1, 100)
y = np.sin(4*np.pi*x)
# Big plot
ax = plt.subplot(111)
plt.plot(x, y, "k", zorder=3, alpha=0.4)
@nicoguaro
nicoguaro / astro_sound.wav
Last active Nov 7, 2018
Convert from ordering in a Hilbert-like curve and a 1D array and vice-versa.
View astro_sound.wav
This file has been truncated, but you can view the full file.
View spline_contour.geo
/*
Programmatically define a mesh for a region enclosed by a curve
given in parametric for for polar coordinates.
Author: Nicolas Guarin-Zapata
Date: October, 2018
*/
size = 0.05;
npts = 50;
@nicoguaro
nicoguaro / line_approx.py
Last active Feb 22, 2021
Minimize the best approximation to points that lie over a straight line with outliers for L^p norm.
View line_approx.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Minimize the best approximation to points that lie over
a straight line with outliers for L^p norm.
@author: Nicolas-Guarin-Zapata
"""
import numpy as np
import matplotlib.pyplot as plt
@nicoguaro
nicoguaro / vtkinterface_example.py
Last active May 4, 2018
Examples of use of vtkInterface for Scientific Visualization in Python using VTK.
View vtkinterface_example.py
import vtkInterface
from vtkInterface import examples
# Load Grid
grid = vtkInterface.UnstructuredGrid(examples.hexbeamfile)
# scalar demo
plobj = vtkInterface.PlotClass()
plobj.AddMesh(grid, scalars=grid.points[:, 2], colormap='viridis')
plobj.AddScalarBar()