O resto dos comentarios
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Iterable, TypeAlias
|
from typing import Any, Iterable
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
|
|
||||||
from utils import stats
|
from utils import stats
|
||||||
|
|
||||||
# -- helpers
|
# -- helpers
|
||||||
|
|
||||||
|
|
||||||
def plot_bar(x, y, xLabel, yLabel, title):
|
def plot_bar(x: ArrayLike, y: ArrayLike, xLabel: str, yLabel: str, title: str) -> None:
|
||||||
"""Funcao para efetuar o plot de um grafico de barras
|
"""Funcao para efetuar o plot de um grafico de barras
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
x ([]): valores em x
|
x (ArrayLike): valores em x
|
||||||
y ([type]): valor y correspondente a cada valor x
|
y (ArrayLike): valor y correspondente a cada valor x
|
||||||
xLabel ([type]): [description]
|
xLabel (str): Nome da linha x
|
||||||
yLabel ([type]): [description]
|
yLabel (str): Nome da linha y
|
||||||
title ([type]): [description]
|
title (str): Titulo do grafico
|
||||||
"""
|
"""
|
||||||
plt.figure(figsize=(10, 6))
|
plt.figure(figsize=(10, 6))
|
||||||
plt.bar(x, y)
|
plt.bar(x, y)
|
||||||
@@ -30,18 +32,18 @@ def plot_bar(x, y, xLabel, yLabel, title):
|
|||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
def plot_linear_with_std(x, mean, std, xLabel, yLabel, title):
|
def plot_linear_with_std(
|
||||||
"""[summary]
|
x: ArrayLike, mean: ArrayLike, std: ArrayLike, xLabel: str, yLabel: str, title: str
|
||||||
|
) -> None:
|
||||||
[description]
|
"""Funcao para efetuar o plot de um grafico linear
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
x ([type]): [description]
|
x (ArrayLike): valores em x
|
||||||
mean ([type]): [description]
|
mean (ArrayLike): valores de media
|
||||||
std ([type]): [description]
|
std (ArrayLike): desvio-padrao
|
||||||
xLabel ([type]): [description]
|
xLabel (str): Nome da linha x
|
||||||
yLabel ([type]): [description]
|
yLabel (str): Nome da linha y
|
||||||
title ([type]): [description]
|
title (str): Titulo do grafico
|
||||||
"""
|
"""
|
||||||
plt.figure(figsize=(10, 6))
|
plt.figure(figsize=(10, 6))
|
||||||
plt.errorbar(x, mean, yerr=std, fmt="-o", capsize=5, ecolor="red")
|
plt.errorbar(x, mean, yerr=std, fmt="-o", capsize=5, ecolor="red")
|
||||||
@@ -54,17 +56,17 @@ def plot_linear_with_std(x, mean, std, xLabel, yLabel, title):
|
|||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
def plot_boxplot(dataList, labels, xLabel, yLabel, title):
|
def plot_boxplot(
|
||||||
"""[summary]
|
dataList: ArrayLike, labels: Sequence, xLabel: str, yLabel: str, title: str
|
||||||
|
) -> None:
|
||||||
[description]
|
"""Funcao para efetuar o plot de um grafico boxplot
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dataList ([type]): [description]
|
dataList (ArrayLike): array com valores
|
||||||
labels ([type]): [description]
|
labels (Sequence): array com nomes para cada valor em `dataList`
|
||||||
xLabel ([type]): [description]
|
xLabel (str): Nome da linha x
|
||||||
yLabel ([type]): [description]
|
yLabel (str): Nome da linha y
|
||||||
title ([type]): [description]
|
title (str): Titulo do grafico
|
||||||
"""
|
"""
|
||||||
# dataList: lista de arrays/series, um para cada etiqueta
|
# dataList: lista de arrays/series, um para cada etiqueta
|
||||||
# labels: lista de etiquetas correspondentes a dataList
|
# labels: lista de etiquetas correspondentes a dataList
|
||||||
@@ -81,15 +83,13 @@ def plot_boxplot(dataList, labels, xLabel, yLabel, title):
|
|||||||
# -- t6 logic
|
# -- t6 logic
|
||||||
|
|
||||||
|
|
||||||
def viz_events_per_period(df: pd.DataFrame, period: str, title_suffix: str):
|
def viz_events_per_period(df: pd.DataFrame, period: str, title_suffix: str) -> None:
|
||||||
"""[summary]
|
"""Prepara dados para serem visualizados por um grafico de barras
|
||||||
|
|
||||||
[description]
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
df (pd.DataFrame): [description]
|
df (pd.DataFrame): dataframe com eventos
|
||||||
period (str): [description]
|
period (str): periodo, em dias ou meses
|
||||||
title_suffix (str): [description]
|
title_suffix (str): sufixo para o nome do titulo do grafico
|
||||||
"""
|
"""
|
||||||
dates, counts = stats.events_per_period(df, period)
|
dates, counts = stats.events_per_period(df, period)
|
||||||
# Formatar datas para melhor leitura no gráfico
|
# Formatar datas para melhor leitura no gráfico
|
||||||
@@ -103,13 +103,11 @@ def viz_events_per_period(df: pd.DataFrame, period: str, title_suffix: str):
|
|||||||
|
|
||||||
|
|
||||||
def viz_linear_stats(df: pd.DataFrame, target: str):
|
def viz_linear_stats(df: pd.DataFrame, target: str):
|
||||||
"""[summary]
|
"""Prepara dados para serem visualizados por um grafico linear
|
||||||
|
|
||||||
[description]
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
df (pd.DataFrame): [description]
|
df (pd.DataFrame): dataframe com eventos
|
||||||
target (str): [description]
|
target (str): Escolha entre magnitude ou profundidade para visualizar
|
||||||
"""
|
"""
|
||||||
# Média +/- Desvio Padrão
|
# Média +/- Desvio Padrão
|
||||||
if target == "Profundidade":
|
if target == "Profundidade":
|
||||||
@@ -132,16 +130,11 @@ def viz_linear_stats(df: pd.DataFrame, target: str):
|
|||||||
|
|
||||||
|
|
||||||
def viz_boxplot(df: pd.DataFrame, target: str):
|
def viz_boxplot(df: pd.DataFrame, target: str):
|
||||||
"""[summary]
|
"""Prepara dados para serem visualizados por um grafico tipo boxplot
|
||||||
|
|
||||||
[description]
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
df (pd.DataFrame): [description]
|
df (pd.DataFrame): dataframe com eventos
|
||||||
target (str): [description]
|
target (str): Escolha entre magnitude ou profundidade para visualizar
|
||||||
|
|
||||||
Returns:
|
|
||||||
[type]: [description]
|
|
||||||
"""
|
"""
|
||||||
events = stats._get_unique_events(df)
|
events = stats._get_unique_events(df)
|
||||||
|
|
||||||
@@ -185,12 +178,10 @@ HEADER = "=== T6: Representação Gráfica ==="
|
|||||||
|
|
||||||
|
|
||||||
def visual_menu(df: pd.DataFrame):
|
def visual_menu(df: pd.DataFrame):
|
||||||
"""
|
"""Menu para visualização gráfica
|
||||||
|
|
||||||
[description]
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
df (pd.DataFrame): [description]
|
df (pd.DataFrame): dataframe com eventos
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
os.system("cls" if sys.platform == "windows" else "clear")
|
os.system("cls" if sys.platform == "windows" else "clear")
|
||||||
|
|||||||
Reference in New Issue
Block a user