Skip to content

Instantly share code, notes, and snippets.

View gVallverdu's full-sized avatar

Germain Salvato Vallverdu gVallverdu

View GitHub Profile
@gVallverdu
gVallverdu / capp_treemaps.py
Last active October 3, 2023 16:52
Treemaps with python and matplotlib
#!/usr/bin/env python3
# coding: utf-8
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import squarify
import platform
# print versions
@gVallverdu
gVallverdu / read_forces.py
Last active February 15, 2023 23:31
Read forces in an OUTCAR file using pymatgen
# This is an example about how to read forces in an OUTCAR file
#
# The forces acting on each ions are provided in an OUTCAR file.
# you can read the table using the Outcar.read_table_pattern() method
# here are the working regex in order to read the forces.
# At the end you get a multiple list with forces as float.
# With last_one_only=False, the first index of the list is the ionic step,
# the second is the atom index and the last is 0, 1 or 2 for f_x, f_y and f_z
# respectively.
#
@gVallverdu
gVallverdu / plot_cmap.py
Last active November 10, 2018 11:10
A convenient function to show a matplotlib color map
import matplotlib.pyplot as plt
def plot_cmap(cmap, ncolor):
"""
A convenient function to plot colors of a matplotlib cmap
Args:
ncolor (int): number of color to show
cmap: a cmap object or a matplotlib color name
"""