pyautoplot 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyautoplot/__init__.py
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
class AutoPlot:
|
|
7
|
+
"""
|
|
8
|
+
A class for automatic and customized data visualization from CSV files.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
data (DataFrame): The dataset loaded from the CSV file.
|
|
12
|
+
categorical (list): List of categorical column names.
|
|
13
|
+
numeric (list): List of numeric column names.
|
|
14
|
+
time_series (list): List of time-series column names.
|
|
15
|
+
|
|
16
|
+
Methods:
|
|
17
|
+
auto_plot(output_file=None, theme="light", excludes=None, **kwargs):
|
|
18
|
+
Automatically analyzes the dataset and generates multiple types of plots.
|
|
19
|
+
|
|
20
|
+
plot(plot_type, x=None, y=None, **kwargs):
|
|
21
|
+
Manually generates a specific plot based on user input.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, csv_path):
|
|
25
|
+
"""
|
|
26
|
+
Initializes the AutoPlot object by loading the dataset and classifying columns.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
csv_path (str): Path to the CSV file to load and analyze.
|
|
30
|
+
"""
|
|
31
|
+
self.data = pd.read_csv(csv_path)
|
|
32
|
+
self.categorical = []
|
|
33
|
+
self.numeric = []
|
|
34
|
+
self.time_series = []
|
|
35
|
+
self._detect_column_types()
|
|
36
|
+
|
|
37
|
+
def _detect_column_types(self):
|
|
38
|
+
"""Detect columns as categorical or numeric based on their content."""
|
|
39
|
+
for column in self.data.columns:
|
|
40
|
+
# Check for time series (datetime-like columns)
|
|
41
|
+
if pd.api.types.is_datetime64_any_dtype(self.data[column]):
|
|
42
|
+
self.time_series.append(column)
|
|
43
|
+
# Check for categorical columns (object dtype or less than 15 unique values)
|
|
44
|
+
elif self.data[column].dtype == 'object' or self.data[column].nunique() < 15:
|
|
45
|
+
self.categorical.append(column)
|
|
46
|
+
# Check for numeric columns (numeric dtype)
|
|
47
|
+
elif pd.api.types.is_numeric_dtype(self.data[column]):
|
|
48
|
+
self.numeric.append(column)
|
|
49
|
+
|
|
50
|
+
def _apply_theme(self, theme):
|
|
51
|
+
"""Apply theme settings for light, dark, or custom themes."""
|
|
52
|
+
if theme == "dark":
|
|
53
|
+
self.theme_settings = {
|
|
54
|
+
"axes.facecolor": "#222222",
|
|
55
|
+
"axes.edgecolor": "#ffffff",
|
|
56
|
+
"axes.labelcolor": "#ffffff",
|
|
57
|
+
"figure.facecolor": "#222222",
|
|
58
|
+
"grid.color": "#444444",
|
|
59
|
+
"text.color": "#ffffff",
|
|
60
|
+
"xtick.color": "#ffffff",
|
|
61
|
+
"ytick.color": "#ffffff",
|
|
62
|
+
"legend.frameon": False
|
|
63
|
+
}
|
|
64
|
+
plt.rcParams.update(self.theme_settings)
|
|
65
|
+
|
|
66
|
+
elif theme == "light":
|
|
67
|
+
self.theme_settings = {
|
|
68
|
+
"axes.facecolor": "#ffffff",
|
|
69
|
+
"axes.edgecolor": "#000000",
|
|
70
|
+
"axes.labelcolor": "#000000",
|
|
71
|
+
"figure.facecolor": "#ffffff",
|
|
72
|
+
"grid.color": "#dddddd",
|
|
73
|
+
"text.color": "#000000",
|
|
74
|
+
"xtick.color": "#000000",
|
|
75
|
+
"ytick.color": "#000000",
|
|
76
|
+
"legend.frameon": True,
|
|
77
|
+
}
|
|
78
|
+
plt.rcParams.update(self.theme_settings)
|
|
79
|
+
|
|
80
|
+
elif isinstance(theme, dict):
|
|
81
|
+
# Check if the theme is a dictionary (custom theme)
|
|
82
|
+
try:
|
|
83
|
+
self.theme_settings = theme
|
|
84
|
+
plt.rcParams.update(self.theme_settings)
|
|
85
|
+
except Exception as e:
|
|
86
|
+
print(f"Error applying custom theme: {e}")
|
|
87
|
+
# Optionally, revert to default or light theme if custom fails
|
|
88
|
+
self._apply_theme("light")
|
|
89
|
+
|
|
90
|
+
else:
|
|
91
|
+
print("Invalid theme specified. Falling back to default (light) theme.")
|
|
92
|
+
self._apply_theme("light")
|
|
93
|
+
|
|
94
|
+
def _generate_analysis(self):
|
|
95
|
+
"""Generate detailed analysis of the dataset."""
|
|
96
|
+
analysis = {}
|
|
97
|
+
|
|
98
|
+
# Numeric Analysis
|
|
99
|
+
for column in self.numeric:
|
|
100
|
+
data_column = self.data[column].dropna() # Drop NaN values for the analysis
|
|
101
|
+
n = len(data_column) # Get the number of valid data points
|
|
102
|
+
mean = data_column.mean()
|
|
103
|
+
stddev = data_column.std()
|
|
104
|
+
skewness = self._calculate_skewness(self, data=data_column, mean=mean, stddev=stddev, n=n)
|
|
105
|
+
kurtosis = self._calculate_kurtosis(self, data=data_column, mean=mean, stddev=stddev, n=n)
|
|
106
|
+
|
|
107
|
+
stats = {
|
|
108
|
+
"Type": "Numeric",
|
|
109
|
+
"Count": n,
|
|
110
|
+
"Mean": mean,
|
|
111
|
+
"Median": data_column.median(),
|
|
112
|
+
"StdDev": stddev,
|
|
113
|
+
"Min": data_column.min(),
|
|
114
|
+
"Max": data_column.max(),
|
|
115
|
+
"Skewness": skewness,
|
|
116
|
+
"Kurtosis": kurtosis,
|
|
117
|
+
"IQR": data_column.quantile(0.75) - data_column.quantile(0.25),
|
|
118
|
+
"25th Percentile": data_column.quantile(0.25),
|
|
119
|
+
"50th Percentile (Median)": data_column.quantile(0.50),
|
|
120
|
+
"75th Percentile": data_column.quantile(0.75),
|
|
121
|
+
"Outliers": self._detect_outliers(data_column),
|
|
122
|
+
"Missing Values": data_column.isnull().sum(),
|
|
123
|
+
}
|
|
124
|
+
analysis[column] = stats
|
|
125
|
+
|
|
126
|
+
# Categorical Analysis
|
|
127
|
+
for column in self.categorical:
|
|
128
|
+
value_counts = self.data[column].value_counts()
|
|
129
|
+
stats = {
|
|
130
|
+
"Type": "Categorical",
|
|
131
|
+
"Count": self.data[column].count(),
|
|
132
|
+
"Unique": self.data[column].nunique(),
|
|
133
|
+
"Most Common": value_counts.idxmax(),
|
|
134
|
+
"Most Common Count": value_counts.max(),
|
|
135
|
+
"Top 3 Most Common": value_counts.head(3).to_dict(),
|
|
136
|
+
"Balance Ratio": self._calculate_balance_ratio(self.data[column]),
|
|
137
|
+
"Frequency Distribution": value_counts.to_dict(),
|
|
138
|
+
"Mode Variability": value_counts[value_counts == value_counts.max()].index.tolist(),
|
|
139
|
+
"Missing Values": data_column.isnull().sum(),
|
|
140
|
+
}
|
|
141
|
+
analysis[column] = stats
|
|
142
|
+
|
|
143
|
+
# Time Series Analysis
|
|
144
|
+
for column in self.time_series:
|
|
145
|
+
data_column = self.data[column].dropna()
|
|
146
|
+
stats = {
|
|
147
|
+
"Type": "Time Series",
|
|
148
|
+
"Count": len(data_column),
|
|
149
|
+
"Min": data_column.min(),
|
|
150
|
+
"Max": data_column.max(),
|
|
151
|
+
"Mean": data_column.mean(),
|
|
152
|
+
"Median": data_column.median(),
|
|
153
|
+
"Missing Values": data_column.isnull().sum(),
|
|
154
|
+
"Seasonality": self._detect_seasonality(data_column),
|
|
155
|
+
"Autocorrelation": self._calculate_autocorrelation(data_column),
|
|
156
|
+
}
|
|
157
|
+
analysis[column] = stats
|
|
158
|
+
|
|
159
|
+
return analysis
|
|
160
|
+
|
|
161
|
+
@staticmethod
|
|
162
|
+
def _calculate_skewness(self, data, mean, stddev, n):
|
|
163
|
+
"""Calculate skewness of a dataset."""
|
|
164
|
+
skewness = np.sum(((data - mean) / stddev) ** 3) / n
|
|
165
|
+
return skewness
|
|
166
|
+
|
|
167
|
+
@staticmethod
|
|
168
|
+
def _calculate_kurtosis(self, data, mean, stddev, n):
|
|
169
|
+
"""Calculate kurtosis of a dataset."""
|
|
170
|
+
kurtosis = (np.sum(((data - mean) / stddev) ** 4) / n) - 3
|
|
171
|
+
return kurtosis
|
|
172
|
+
|
|
173
|
+
@staticmethod
|
|
174
|
+
def _calculate_autocorrelation(self, data):
|
|
175
|
+
"""Calculate autocorrelation at various lags."""
|
|
176
|
+
mean = data.mean()
|
|
177
|
+
autocorrelations = []
|
|
178
|
+
for lag in range(1, 11): # Calculate autocorrelation for lags 1 through 10
|
|
179
|
+
lagged_data = data.shift(lag)
|
|
180
|
+
correlation = data.corr(lagged_data)
|
|
181
|
+
autocorrelations.append(correlation)
|
|
182
|
+
return autocorrelations
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@staticmethod
|
|
186
|
+
def _detect_outliers(series, threshold=3):
|
|
187
|
+
"""Detect outliers in a numeric series based on standard deviation."""
|
|
188
|
+
mean = series.mean()
|
|
189
|
+
std_dev = series.std()
|
|
190
|
+
outliers = series[(series < mean - threshold * std_dev) | (series > mean + threshold * std_dev)]
|
|
191
|
+
return outliers.tolist()
|
|
192
|
+
|
|
193
|
+
@staticmethod
|
|
194
|
+
def _calculate_balance_ratio(series):
|
|
195
|
+
"""Calculate balance ratio for a categorical series."""
|
|
196
|
+
value_counts = series.value_counts()
|
|
197
|
+
most_common = value_counts.max()
|
|
198
|
+
least_common = value_counts.min()
|
|
199
|
+
return f"{most_common}:{least_common} (Most:Least)"
|
|
200
|
+
|
|
201
|
+
def _plot_detailed_analysis(self, analysis, output_file=None):
|
|
202
|
+
"""Create a summary plot showing the detailed analysis for all variables."""
|
|
203
|
+
total_vars = len(analysis)
|
|
204
|
+
fig, axes = plt.subplots(total_vars, 1, figsize=(20, total_vars * 4), constrained_layout=True)
|
|
205
|
+
axes = axes if total_vars > 1 else [axes] # Handle a single variable case
|
|
206
|
+
|
|
207
|
+
fig.suptitle("Detailed Dataset Analysis", fontsize=20, weight="bold", y=1.02)
|
|
208
|
+
|
|
209
|
+
for i, (column, stats) in enumerate(analysis.items()):
|
|
210
|
+
ax = axes[i]
|
|
211
|
+
stat_text = "\n".join(f"{key}: {value}" for key, value in stats.items())
|
|
212
|
+
|
|
213
|
+
# Set up bbox with increased padding for larger boxes
|
|
214
|
+
bbox_props = dict(facecolor=self.theme_settings['axes.facecolor'], edgecolor=self.theme_settings['axes.edgecolor'], alpha=0.8)
|
|
215
|
+
|
|
216
|
+
# Adjust text positioning to allow more room
|
|
217
|
+
ax.text(0.5, 0.5, stat_text, fontsize=12, verticalalignment="center", horizontalalignment="center", transform=ax.transAxes, bbox=bbox_props)
|
|
218
|
+
|
|
219
|
+
ax.axis("off") # Hide axes since this is a text-only section
|
|
220
|
+
ax.set_title(f"Analysis of {column}", fontsize=16, pad=20, weight="bold") # Increased padding to make space for the title
|
|
221
|
+
|
|
222
|
+
if output_file:
|
|
223
|
+
plt.savefig(output_file, dpi=300)
|
|
224
|
+
plt.show()
|
|
225
|
+
|
|
226
|
+
def auto_plot(self, output_file=None, theme="light", excludes=None, **kwargs):
|
|
227
|
+
"""
|
|
228
|
+
Automatically analyze the dataset and generate visualizations.
|
|
229
|
+
|
|
230
|
+
This method produces:
|
|
231
|
+
1. Detailed analysis summary as a text-based plot.
|
|
232
|
+
2. Numeric visualizations: Histograms, Boxplots, and Pairwise Scatter Matrix.
|
|
233
|
+
3. Categorical visualizations: Enhanced Bar Plots and Pie Charts.
|
|
234
|
+
4. Time-series visualizations: Line and Stacked Area Plots.
|
|
235
|
+
|
|
236
|
+
Parameters:
|
|
237
|
+
output_file (str, optional): Base filename for saving plots. Default is None (no saving).
|
|
238
|
+
theme (str, optional): Plot theme ("light", "dark", or a custom dictionary). Default is "light".
|
|
239
|
+
excludes (list, optional): Sections to exclude from plotting, e.g., ["histograms"]. Default is None.
|
|
240
|
+
**kwargs: Additional keyword arguments passed to plot methods.
|
|
241
|
+
|
|
242
|
+
Examples:
|
|
243
|
+
autoplot.auto_plot(output_file="dataset_output", theme="dark", excludes=["pie_charts"])
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
# Initialize the excludes parameter if not provided
|
|
247
|
+
if excludes is None:
|
|
248
|
+
excludes = []
|
|
249
|
+
|
|
250
|
+
self._apply_theme(theme)
|
|
251
|
+
|
|
252
|
+
# Handle the base filename and extension
|
|
253
|
+
if output_file:
|
|
254
|
+
base_filename, file_extension = os.path.splitext(output_file)
|
|
255
|
+
|
|
256
|
+
# Section 1: Detailed Analysis Summary
|
|
257
|
+
if "detailed_analysis" not in excludes:
|
|
258
|
+
analysis = self._generate_analysis()
|
|
259
|
+
self._plot_detailed_analysis(analysis, output_file=f"{base_filename}_analysis{file_extension}")
|
|
260
|
+
|
|
261
|
+
# Section 2: Numeric Distributions and Boxplots
|
|
262
|
+
if self.numeric and "numeric" not in excludes:
|
|
263
|
+
fig, axes = plt.subplots(len(self.numeric), 2, figsize=(18, len(self.numeric) * 5), constrained_layout=True)
|
|
264
|
+
axes = axes if len(self.numeric) > 1 else [axes] # Handle single numeric column
|
|
265
|
+
|
|
266
|
+
fig.suptitle("Numeric Variables: Distributions and Boxplots", fontsize=20, weight="bold", y=1.02)
|
|
267
|
+
|
|
268
|
+
for i, column in enumerate(self.numeric):
|
|
269
|
+
# Histogram
|
|
270
|
+
self.data[column].plot(kind='hist', ax=axes[i][0], title=f"Distribution of {column}", **kwargs)
|
|
271
|
+
axes[i][0].set_xlabel(column)
|
|
272
|
+
axes[i][0].set_ylabel("Frequency")
|
|
273
|
+
|
|
274
|
+
# Boxplot
|
|
275
|
+
self.data.boxplot(column=column, ax=axes[i][1], **kwargs)
|
|
276
|
+
axes[i][1].set_title(f"Boxplot of {column}")
|
|
277
|
+
|
|
278
|
+
if output_file:
|
|
279
|
+
# Save Numeric section plots
|
|
280
|
+
plt.savefig(f"{base_filename}_numeric{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
281
|
+
|
|
282
|
+
# Section 3: Enhanced Bar Plots for Categorical Variables
|
|
283
|
+
if self.categorical and "categorical" not in excludes:
|
|
284
|
+
fig_cat, ax_cat = plt.subplots(len(self.categorical), 1, figsize=(18, len(self.categorical) * 5), constrained_layout=True)
|
|
285
|
+
ax_cat = ax_cat if len(self.categorical) > 1 else [ax_cat]
|
|
286
|
+
|
|
287
|
+
fig_cat.suptitle("Categorical Variables: Enhanced Bar Plots", fontsize=20, weight="bold", y=1.02)
|
|
288
|
+
|
|
289
|
+
for j, cat_column in enumerate(self.categorical):
|
|
290
|
+
value_counts = self.data[cat_column].value_counts()
|
|
291
|
+
max_value = value_counts.max()
|
|
292
|
+
min_value = value_counts.min()
|
|
293
|
+
avg_value = value_counts.mean()
|
|
294
|
+
|
|
295
|
+
value_counts.plot(kind="bar", ax=ax_cat[j], title=f"Bar Plot of {cat_column}", **kwargs)
|
|
296
|
+
ax_cat[j].set_xlabel(cat_column)
|
|
297
|
+
ax_cat[j].set_ylabel("Count")
|
|
298
|
+
|
|
299
|
+
# Annotate bar plot with statistics
|
|
300
|
+
ax_cat[j].text(
|
|
301
|
+
0.02, 0.95,
|
|
302
|
+
f"Max: {max_value}\nMin: {min_value}\nAvg: {avg_value:.2f}",
|
|
303
|
+
transform=ax_cat[j].transAxes,
|
|
304
|
+
fontsize=10,
|
|
305
|
+
verticalalignment="top",
|
|
306
|
+
bbox=dict(facecolor=self.theme_settings['axes.facecolor'], edgecolor=self.theme_settings['axes.edgecolor'], alpha=0.8)
|
|
307
|
+
)
|
|
308
|
+
if output_file:
|
|
309
|
+
# Save Categorical section plots
|
|
310
|
+
plt.savefig(f"{base_filename}_categorical{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
311
|
+
|
|
312
|
+
# Section 4: Pairwise Scatter Plots for Numeric Variables
|
|
313
|
+
if len(self.numeric) > 1 and "pairwise_scatter" not in excludes:
|
|
314
|
+
fig_scatter, axes_scatter = plt.subplots(len(self.numeric), len(self.numeric), figsize=(20, 20), constrained_layout=True)
|
|
315
|
+
|
|
316
|
+
fig_scatter.suptitle("Pairwise Scatter Plots of Numeric Variables", fontsize=20, weight="bold", y=1.02)
|
|
317
|
+
|
|
318
|
+
for i, col_x in enumerate(self.numeric):
|
|
319
|
+
for j, col_y in enumerate(self.numeric):
|
|
320
|
+
if i == j:
|
|
321
|
+
# Diagonal: Histogram for the variable
|
|
322
|
+
self.data[col_x].plot(kind="hist", ax=axes_scatter[i][j], title=f"{col_x} Distribution", **kwargs)
|
|
323
|
+
axes_scatter[i][j].set_xlabel(col_x)
|
|
324
|
+
else:
|
|
325
|
+
# Off-diagonal: Scatter plot
|
|
326
|
+
self.data.plot.scatter(x=col_x, y=col_y, ax=axes_scatter[i][j], **kwargs)
|
|
327
|
+
axes_scatter[i][j].set_title(f"{col_x} vs {col_y}")
|
|
328
|
+
|
|
329
|
+
if output_file:
|
|
330
|
+
# Save Pairwise section plots
|
|
331
|
+
plt.savefig(f"{base_filename}_pairwise{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
332
|
+
|
|
333
|
+
# Section 5: Pie Charts for Categorical Variables
|
|
334
|
+
if self.categorical and "pie_charts" not in excludes:
|
|
335
|
+
for cat_column in self.categorical:
|
|
336
|
+
value_counts = self.data[cat_column].value_counts()
|
|
337
|
+
fig_pie, ax_pie = plt.subplots(figsize=(8, 8))
|
|
338
|
+
|
|
339
|
+
value_counts.plot(kind="pie", ax=ax_pie, autopct='%1.1f%%', title=f"Pie Chart of {cat_column}", **kwargs)
|
|
340
|
+
ax_pie.set_ylabel("") # Remove the default ylabel (it can clutter the plot)
|
|
341
|
+
|
|
342
|
+
if output_file:
|
|
343
|
+
# Save Pie section plots
|
|
344
|
+
plt.savefig(f"{base_filename}_pie_{cat_column}{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
345
|
+
|
|
346
|
+
# Section 6: Line Plots for Time Series Data
|
|
347
|
+
if self.time_series and "line_plots" not in excludes: # Assuming self.time_series contains time series columns
|
|
348
|
+
for time_col in self.time_series:
|
|
349
|
+
fig_line, ax_line = plt.subplots(figsize=(10, 6))
|
|
350
|
+
self.data[time_col].plot(kind="line", ax=ax_line, title=f"Line Plot of {time_col}", **kwargs)
|
|
351
|
+
ax_line.set_xlabel("Time")
|
|
352
|
+
ax_line.set_ylabel(time_col)
|
|
353
|
+
|
|
354
|
+
if output_file:
|
|
355
|
+
# Save Line plot section
|
|
356
|
+
plt.savefig(f"{base_filename}_line_{time_col}{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
357
|
+
|
|
358
|
+
# Section 7: Stacked Area Plots for Time Series Data
|
|
359
|
+
if self.time_series and "stacked_area" not in excludes: # If self.time_series contains multiple time series columns for stacking
|
|
360
|
+
fig_area, ax_area = plt.subplots(figsize=(12, 8))
|
|
361
|
+
self.data[self.time_series].plot.area(ax=ax_area, title="Stacked Area Plot of Time Series Data", **kwargs)
|
|
362
|
+
ax_area.set_xlabel("Time")
|
|
363
|
+
ax_area.set_ylabel("Values")
|
|
364
|
+
|
|
365
|
+
if output_file:
|
|
366
|
+
# Save Stacked Area section plot
|
|
367
|
+
plt.savefig(f"{base_filename}_stacked_area{file_extension}", dpi=kwargs.get("dpi", 300))
|
|
368
|
+
|
|
369
|
+
# Show all generated plots
|
|
370
|
+
plt.show()
|
|
371
|
+
|
|
372
|
+
def plot(self, plot_type, x=None, y=None, **kwargs):
|
|
373
|
+
"""
|
|
374
|
+
Generate a specific type of plot manually.
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
plot_type (str): Type of plot to generate. Options include:
|
|
378
|
+
- "scatter": Scatter plot (requires x and y).
|
|
379
|
+
- "distribution": Histogram (requires x).
|
|
380
|
+
- "boxplot": Boxplot (requires x).
|
|
381
|
+
- "bar": Bar chart (requires x).
|
|
382
|
+
x (str, optional): Name of the column for the x-axis or primary data. Default is None.
|
|
383
|
+
y (str, optional): Name of the column for the y-axis (for scatter plots). Default is None.
|
|
384
|
+
**kwargs: Additional keyword arguments for the plot.
|
|
385
|
+
|
|
386
|
+
Examples:
|
|
387
|
+
autoplot.plot(plot_type="scatter", x="age", y="income")
|
|
388
|
+
autoplot.plot(plot_type="distribution", x="salary", bins=20)
|
|
389
|
+
"""
|
|
390
|
+
if plot_type == "scatter" and x and y:
|
|
391
|
+
self.data.plot.scatter(x=x, y=y, **kwargs)
|
|
392
|
+
elif plot_type == "distribution" and x:
|
|
393
|
+
self.data[x].plot(kind="hist", **kwargs)
|
|
394
|
+
elif plot_type == "boxplot" and x:
|
|
395
|
+
self.data.boxplot(column=x, **kwargs)
|
|
396
|
+
elif plot_type == "bar" and x:
|
|
397
|
+
self.data[x].value_counts().plot(kind="bar", **kwargs)
|
|
398
|
+
plt.show()
|
|
399
|
+
|
|
400
|
+
def customize(self, **kwargs):
|
|
401
|
+
"""Update global plot settings."""
|
|
402
|
+
plt.rcParams.update(kwargs)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
MIT License (Modified)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to make derivative works based on the Software, provided that any substantial changes to the Software are clearly distinguished from the original work and are distributed under a different name.
|
|
4
|
+
|
|
5
|
+
The original copyright notice and disclaimer must be retained in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pyautoplot
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: PyAutoPlot is an open-source Python library designed to make dataset analysis much easier by generating helpful detailed plots using matplotlib based on your dataset.
|
|
5
|
+
Home-page: https://github.com/infinitode/pyautoplot
|
|
6
|
+
Author: Infinitode Pty Ltd
|
|
7
|
+
Author-email: infinitode.ltd@gmail.com
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.6
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: requires-python
|
|
29
|
+
Dynamic: summary
|
|
30
|
+
|
|
31
|
+
# PyAutoPlot
|
|
32
|
+

|
|
33
|
+
[](https://github.com/infinitode/pyautoplot)
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
PyAutoPlot is an open-source Python library designed to make dataset analysis much easier by generating helpful detailed plots using `matplotlib`. It automatically generates appropriate plots based on the dataset you feed it.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
You can install PyAutoPlot using pip:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install pyautoplot
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Supported Python Versions
|
|
49
|
+
|
|
50
|
+
PyAutoPlot supports the following Python versions:
|
|
51
|
+
|
|
52
|
+
- Python 3.6
|
|
53
|
+
- Python 3.7
|
|
54
|
+
- Python 3.8
|
|
55
|
+
- Python 3.9
|
|
56
|
+
- Python 3.10
|
|
57
|
+
- Python 3.11/Later (Preferred)
|
|
58
|
+
|
|
59
|
+
Please ensure that you have one of these Python versions installed before using PyAutoPlot. PyAutoPlot may not work as expected on lower versions of Python than the supported.
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
- **Automatic Plotting**: PyAutoPlot automatically generates appropriate plots based on values present in your dataset. Currently, PyAutoPlot supports the following types of data: `numeric`, `categorical`, and `time-series`.
|
|
64
|
+
- **Customization**: Due to matplotlib's high customizability, you can create and use custom themes for PyAutoPlot, just pass in your theme as a dictionary of RCParams (See `plot.rcParams.keys()` for a list of valid parameters) or choose from our predefined themes. You can also pass in additional parameters to the function that `matplotlib` can recognize (e.g. `color='#5d17eb'`).
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
### AutoPlot
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from pyautoplot import AutoPlot
|
|
72
|
+
|
|
73
|
+
# Initialize with a CSV file
|
|
74
|
+
plotter = AutoPlot("path/to/dataset.csv")
|
|
75
|
+
|
|
76
|
+
# Automatically analyze and plot
|
|
77
|
+
plotter.auto_plot(output_file='test', theme="dark", color='orange', excludes=['detailed_analysis'])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
> [!NOTE]
|
|
81
|
+
> PyAutoPlot may not work well with certain datasets. If you find any issues please open an issue.
|
|
82
|
+
|
|
83
|
+
### Customization
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from pyautoplot import AutoPlot
|
|
87
|
+
|
|
88
|
+
# Define your custom theme
|
|
89
|
+
custom_theme = {
|
|
90
|
+
"axes.facecolor": "#ffffff",
|
|
91
|
+
"axes.edgecolor": "#000000",
|
|
92
|
+
"axes.labelcolor": "#000000",
|
|
93
|
+
"figure.facecolor": "#ffffff",
|
|
94
|
+
"grid.color": "#dddddd",
|
|
95
|
+
"text.color": "#000000",
|
|
96
|
+
"xtick.color": "#000000",
|
|
97
|
+
"ytick.color": "#000000",
|
|
98
|
+
"legend.frameon": True,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Initialize with a CSV file
|
|
102
|
+
plotter = AutoPlot("path/to/dataset.csv")
|
|
103
|
+
|
|
104
|
+
# Automatically analyze and plot using the custom theme
|
|
105
|
+
plotter.auto_plot(output_file='test', theme=custom_theme, color='orange', excludes=['detailed_analysis'])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute to PyAutoPlot, please open an issue or submit a pull request on [GitHub](https://github.com/infinitode/pyautoplot).
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
PyAutoPlot is released under the terms of the **MIT License (Modified)**. Please see the [LICENSE](https://github.com/infinitode/pyautoplot/blob/main/LICENSE) file for the full text.
|
|
115
|
+
|
|
116
|
+
**Modified License Clause**
|
|
117
|
+
|
|
118
|
+
The modified license clause grants users the permission to make derivative works based on the PyAutoPlot software. However, it requires any substantial changes to the software to be clearly distinguished from the original work and distributed under a different name.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pyautoplot/__init__.py,sha256=h0KQxQhYVlFOoa8zHxRy38h1ptkPfApXKcA4W_1F0Jo,18378
|
|
2
|
+
pyautoplot-1.0.0.dist-info/LICENSE,sha256=ZIftxnYzzlrappVuiyXoFI6QAiB1s2fzg9w07mxF-QI,949
|
|
3
|
+
pyautoplot-1.0.0.dist-info/METADATA,sha256=Ec-STZ_alrChPan-1PYLh7_pRf3II35jrOZvDtWn0zo,4607
|
|
4
|
+
pyautoplot-1.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
5
|
+
pyautoplot-1.0.0.dist-info/top_level.txt,sha256=Neluemp1uAnEOVArWj2PyojDYdl0na5fkhY0O52ToRo,11
|
|
6
|
+
pyautoplot-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyautoplot
|