Skip to content

Instantly share code, notes, and snippets.

@kapil1987
kapil1987 / SharedLib_CMakeLists.txt
Created June 6, 2019 10:56
CMakeLists.txt for static, shared and executable
# Minimum cmake version required
cmake_minimum_required(VERSION 3.5.1)
# Set project name. This command also sets the
# variable PROJECT_SOURCE_DIR which will be used
# below
project(Geometry)
# CMAKE VARIABLE - SRC. Points to all the source files
# used to compile this library
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Read the csv file into a pandas dataframe
# A dataframe is basically a table of data.
df_housing = pd.read_csv("housing.csv")
# Get figure object and an array of axes objects
fig, arr_ax = plt.subplots(2, 2)
@kapil1987
kapil1987 / Matplotlib_plt_subplots.py
Last active February 27, 2019 06:00
pyplot subplots method
import matplotlib.pyplot as plt
fig, arr_ax = plt.subplots(2,2)
# arr_ax is a 2d array of axes objects
arr_ax[0,0].set_title('First subplot')
arr_ax[0,1].set_title('Second subplot')
arr_ax[1,0].set_xlabel('Third subplot')
arr_ax[1,1].set_xlabel('Fourth subplot')
@kapil1987
kapil1987 / Matplotlib_Empty2By2GridOfSubplots.py
Last active March 6, 2019 05:47
Matplotlib : Empty 2x2 grid of subplots
import matplotlib.pyplot as plt
fig = plt.figure()
# Generate a grid of 2x2 subplots and get
# axes object for 1st location
ax1 = fig.add_subplot(2,2,1)
ax1.set_title('First Location')
# Get the axes object for subplot at 2nd
@kapil1987
kapil1987 / Matplotlib_TwoSubplotsInAFig.py
Last active February 27, 2019 06:01
Matplotlib : Two subplots in a figure
import matplotlib.pyplot as plt
# Function to get the square of each element in the list
def list_square(a_list):
return [element**2 for element in a_list]
# Multiple subplots in same figure
fig3 = plt.figure()
x = [1, 2, 3, 4, 5]
y = x
@kapil1987
kapil1987 / Matplotlib_MultipleGraphsInSinglePlot.py
Created February 25, 2019 10:37
Multiple graphs in single plot
import matplotlib.pyplot as plt
# Function to get the square of each element in the list
def list_square(a_list):
return [element**2 for element in a_list]
# Multiple plot in same subplot window
# plot y = x and z = x^2 in the same subplot window
fig2 = plt.figure()
import matplotlib.pyplot as plt
# Generate data for plots
x = [1, 2, 3, 4, 5]
y = x
# Get an empty figure
fig1 = plt.figure()
# Get the axes instance at 1st location in 1x1 grid
@kapil1987
kapil1987 / HistogramPlots.py
Last active February 27, 2019 06:02
Histogram plot using matplotlib
# coding: utf-8
import matplotlib.pyplot as plt
import numpy as np
# Generate 1000 numbers from gaussian sample
mean = 10
std = 0.5
num_samples = 1000
@kapil1987
kapil1987 / Matplotlib_OO_Interface.ipynb
Last active May 22, 2020 06:39
Matplotlib object oriented interface
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.