Skip to content

Instantly share code, notes, and snippets.

View muhammadanas0716's full-sized avatar
👽
Alienating

Muhammad Anas muhammadanas0716

👽
Alienating
View GitHub Profile
import sys
import os
from PIL import Image, ImageOps
def overlay_shirt_on_image(input_path, output_path):
"""Overlay a transparent-background shirt image onto an input image."""
# Validate the extensions
input_ext = get_file_extension(input_path)
output_ext = get_file_extension(output_path)
@muhammadanas0716
muhammadanas0716 / 𝐏𝐥𝐨𝐭𝐭𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐝𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐭 𝐬𝐜𝐚𝐥𝐞𝐬 𝐮𝐬𝐢𝐧𝐠 𝐚 𝐬𝐞𝐜𝐨𝐧𝐝𝐚𝐫𝐲 𝐘 𝐚𝐱𝐢𝐬
Created March 1, 2023 10:17
Show two-time series that measures 2 different quantities at the same point in time, you can plot the second series against the secondary Y axis on the right.
# Import libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Import Data
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/economics.csv")
x = df['date']
@muhammadanas0716
muhammadanas0716 / ViolinPlots.py
Created February 16, 2023 16:35
Violin plots are used to visualize the distribution of a continuous variable. They are similar to box plots, but provide more information about the shape and density of the distribution. In a violin plot, a kernel density plot is drawn on each side of a central box. The box represents the interquartile range (IQR) of the data, with the median sh…
# Import libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Import Data
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mpg_ggplot2.csv")
@muhammadanas0716
muhammadanas0716 / PyramidPlots.py
Created February 14, 2023 17:03
Population pyramid can be used to show either the distribution of the groups ordered by the volumne. Or it can also be used to show the stage-by-stage filtering of the population as it is used below to show how many people pass through each stage of a marketing funnel.
# Import lbs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Read data
df = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/email_campaign_funnel.csv")
@muhammadanas0716
muhammadanas0716 / SlopeChart.py
Created January 28, 2023 16:11
Slope chart is most suitable for comparing the ‘Before’ and ‘After’ positions of a given person/item.
# Import the needed libs
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.lines as mlines
# Import Data
df = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/gdppercap.csv")
@muhammadanas0716
muhammadanas0716 / AreaChart.py
Created January 25, 2023 07:52
By coloring the area between the axis and the lines, the area chart throws more emphasis not just on the peaks and troughs but also the duration of the highs and lows. The longer the duration of the highs, the larger is the area under the line.
# Import needed libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
# Import the needed libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Prepare Data
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mtcars.csv")
x = df.loc[:, ['mpg']]
@muhammadanas0716
muhammadanas0716 / DivergingPlots.py
Created January 23, 2023 15:49
The diverging bars are a good way to see how different things change based on one measure. It helps you see the difference in the performance of groups in your data and is easy to understand and shows the point clearly
# Import the needed libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Prepare Data
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mtcars.csv")
x = df.loc[:, ['mpg']]
@muhammadanas0716
muhammadanas0716 / Pairwise Plot.py
Created January 21, 2023 04:13
📈📈 Pairwise plot is a favorite in exploratory analysis to understand the relationship between all possible pairs of numeric variables. It is a must-have tool for bivariate analysis. 📉📉
# Import needed libs
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Load Dataset
df = sns.load_dataset('iris')
@muhammadanas0716
muhammadanas0716 / Correlogram.py
Created January 20, 2023 15:42
Correlogram is used to visually see the correlation metric between all possible pairs of numeric variables in a given dataframe (or 2D array).
# Import the needed libraries
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Import Dataset
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mtcars.csv")