myplot 0.1.0__tar.gz
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.
- myplot-0.1.0/.claude/settings.local.json +18 -0
- myplot-0.1.0/.gitignore +10 -0
- myplot-0.1.0/.idea/.gitignore +3 -0
- myplot-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- myplot-0.1.0/.idea/misc.xml +7 -0
- myplot-0.1.0/.idea/modules.xml +8 -0
- myplot-0.1.0/.idea/test_proj.iml +8 -0
- myplot-0.1.0/.idea/vcs.xml +6 -0
- myplot-0.1.0/.idea/workspace.xml +83 -0
- myplot-0.1.0/.python-version +1 -0
- myplot-0.1.0/MYPLOT_REVISION.md +244 -0
- myplot-0.1.0/PKG-INFO +78 -0
- myplot-0.1.0/README.md +69 -0
- myplot-0.1.0/_myplot.py +257 -0
- myplot-0.1.0/imags/plot.png +0 -0
- myplot-0.1.0/main.py +21 -0
- myplot-0.1.0/myplot/README.md +98 -0
- myplot-0.1.0/myplot/__init__.py +427 -0
- myplot-0.1.0/pyproject.toml +17 -0
- myplot-0.1.0/requirements.txt +2 -0
- myplot-0.1.0/setup.py +44 -0
- myplot-0.1.0/uv.lock +368 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(ls -la *.png)",
|
|
5
|
+
"Bash(source .venv/bin/activate)",
|
|
6
|
+
"Bash(python simple_test.py)",
|
|
7
|
+
"Bash(pkill -f simple_test.py)",
|
|
8
|
+
"Bash(python minimal_test.py)",
|
|
9
|
+
"Bash(ls -la *.py)",
|
|
10
|
+
"Bash(python -c \":*)",
|
|
11
|
+
"Bash(python test_chinese_font.py)",
|
|
12
|
+
"Bash(python verify_fix.py)",
|
|
13
|
+
"Bash(find . -name \"__pycache__\" -type d -exec rm -rf {} +)",
|
|
14
|
+
"Bash(pip install:*)",
|
|
15
|
+
"Bash(uv pip:*)"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
myplot-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="Black">
|
|
4
|
+
<option name="sdkName" value="Python 3.9" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="uv (test_proj)" project-jdk-type="Python SDK" />
|
|
7
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/test_proj.iml" filepath="$PROJECT_DIR$/.idea/test_proj.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="jdk" jdkName="uv (test_proj)" jdkType="Python SDK" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="AutoImportSettings">
|
|
4
|
+
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ChangeListManager">
|
|
7
|
+
<list default="true" id="de8659a8-0ff7-414d-89d4-38937666c9c1" name="Changes" comment="">
|
|
8
|
+
<change afterPath="$PROJECT_DIR$/_myplot.py" afterDir="false" />
|
|
9
|
+
</list>
|
|
10
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
11
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
12
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
13
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
14
|
+
</component>
|
|
15
|
+
<component name="Git.Settings">
|
|
16
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
17
|
+
</component>
|
|
18
|
+
<component name="ProjectColorInfo">{
|
|
19
|
+
"associatedIndex": 1
|
|
20
|
+
}</component>
|
|
21
|
+
<component name="ProjectId" id="3ATYfxqXotcuKLMePw5qNwgwjDS" />
|
|
22
|
+
<component name="ProjectViewState">
|
|
23
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
24
|
+
<option name="showLibraryContents" value="true" />
|
|
25
|
+
</component>
|
|
26
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
27
|
+
"keyToString": {
|
|
28
|
+
"Python.main.executor": "Run",
|
|
29
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
30
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
31
|
+
"git-widget-placeholder": "master",
|
|
32
|
+
"last_opened_file_path": "/Users/robert/Projects/test_proj",
|
|
33
|
+
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
|
|
34
|
+
}
|
|
35
|
+
}]]></component>
|
|
36
|
+
<component name="RecentsManager">
|
|
37
|
+
<key name="CopyFile.RECENT_KEYS">
|
|
38
|
+
<recent name="$PROJECT_DIR$" />
|
|
39
|
+
</key>
|
|
40
|
+
</component>
|
|
41
|
+
<component name="RunManager">
|
|
42
|
+
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
|
43
|
+
<module name="test_proj" />
|
|
44
|
+
<option name="ENV_FILES" value="" />
|
|
45
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
|
46
|
+
<option name="PARENT_ENVS" value="true" />
|
|
47
|
+
<envs>
|
|
48
|
+
<env name="PYTHONUNBUFFERED" value="1" />
|
|
49
|
+
</envs>
|
|
50
|
+
<option name="SDK_HOME" value="" />
|
|
51
|
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
52
|
+
<option name="IS_MODULE_SDK" value="true" />
|
|
53
|
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
|
54
|
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
55
|
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
|
56
|
+
<option name="PARAMETERS" value="" />
|
|
57
|
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
|
58
|
+
<option name="EMULATE_TERMINAL" value="false" />
|
|
59
|
+
<option name="MODULE_MODE" value="false" />
|
|
60
|
+
<option name="REDIRECT_INPUT" value="false" />
|
|
61
|
+
<option name="INPUT_FILE" value="" />
|
|
62
|
+
<method v="2" />
|
|
63
|
+
</configuration>
|
|
64
|
+
</component>
|
|
65
|
+
<component name="SharedIndexes">
|
|
66
|
+
<attachedChunks>
|
|
67
|
+
<set>
|
|
68
|
+
<option value="bundled-python-sdk-4f4e415b4190-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.26053.29" />
|
|
69
|
+
</set>
|
|
70
|
+
</attachedChunks>
|
|
71
|
+
</component>
|
|
72
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
73
|
+
<component name="TaskManager">
|
|
74
|
+
<task active="true" id="Default" summary="Default task">
|
|
75
|
+
<changelist id="de8659a8-0ff7-414d-89d4-38937666c9c1" name="Changes" comment="" />
|
|
76
|
+
<created>1772618135045</created>
|
|
77
|
+
<option name="number" value="Default" />
|
|
78
|
+
<option name="presentableId" value="Default" />
|
|
79
|
+
<updated>1772618135045</updated>
|
|
80
|
+
</task>
|
|
81
|
+
<servers />
|
|
82
|
+
</component>
|
|
83
|
+
</project>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# MyPlot Module Revisions - Comprehensive Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document details the comprehensive improvements made to transform the original `_myplot.py` script into a proper, reusable Python module with enhanced functionality.
|
|
5
|
+
|
|
6
|
+
## Original Issues Identified
|
|
7
|
+
|
|
8
|
+
### 1. **No OS Detection**
|
|
9
|
+
- **Problem**: Used hardcoded `Path(__file__).parents[2]` which assumed specific project structure
|
|
10
|
+
- **Impact**: Would fail on different directory structures or systems
|
|
11
|
+
|
|
12
|
+
### 2. **Limited Font Detection**
|
|
13
|
+
- **Problem**: Only searched project directory for `SourceHanSerifSC-Medium.otf`
|
|
14
|
+
- **Impact**: Font detection would fail if font was installed elsewhere on system
|
|
15
|
+
|
|
16
|
+
### 3. **Not a Proper Module**
|
|
17
|
+
- **Problem**: Code ran at module level with side effects, making it unsuitable for reuse
|
|
18
|
+
- **Impact**: Could cause conflicts when imported multiple times
|
|
19
|
+
|
|
20
|
+
## Implementation Plan & Changes
|
|
21
|
+
|
|
22
|
+
### 1. ✅ Module Structure
|
|
23
|
+
```python
|
|
24
|
+
myplot/
|
|
25
|
+
├── __init__.py # Main module code
|
|
26
|
+
└── README.md # Documentation
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. ✅ Cross-Platform OS Detection
|
|
30
|
+
|
|
31
|
+
### 3. ✅ Enhanced Font Detection System
|
|
32
|
+
- **Search Strategy**: Multiple fallback locations
|
|
33
|
+
- **Font Variants**: Searches for multiple versions
|
|
34
|
+
- **Family Name Fix**: Corrects font family name to 'Source Han Serif' instead of 'Source Han Serif SC'
|
|
35
|
+
|
|
36
|
+
### 4. ✅ Modular Code Architecture
|
|
37
|
+
- Added `import platform` to detect system type
|
|
38
|
+
- Implemented platform-specific path handling:
|
|
39
|
+
- **Windows**: `C:\Windows\Fonts`, `%USERPROFILE%\AppData\Local\myplot`
|
|
40
|
+
- **macOS**: `/System/Library/Fonts`, `/Library/Fonts`, `~/Library/Application Support/myplot`
|
|
41
|
+
- **Linux**: `/usr/share/fonts`, `~/.config/myplot`
|
|
42
|
+
|
|
43
|
+
### 3. ✅ Enhanced Font Detection System
|
|
44
|
+
- **Search Strategy**: Multiple fallback locations
|
|
45
|
+
1. System font directories (platform-specific)
|
|
46
|
+
2. User font directories
|
|
47
|
+
3. Project local directories (fonts/, resources/fonts/, src/fonts/)
|
|
48
|
+
4. Current directory
|
|
49
|
+
|
|
50
|
+
- **Font Variants**: Searches for multiple versions:
|
|
51
|
+
- `SourceHanSerifSC-Medium.otf`
|
|
52
|
+
- `SourceHanSerif-Medium.otf`
|
|
53
|
+
- `SourceHanSerifSC-Regular.otf`
|
|
54
|
+
- `SourceHanSerif-Regular.otf`
|
|
55
|
+
- `SourceHanSerif-Heavy.otf`
|
|
56
|
+
- `NotoSerifCJK-Regular.otf` (Alternative)
|
|
57
|
+
- `NotoSerifCJK-Medium.otf` (Alternative)
|
|
58
|
+
|
|
59
|
+
### 4. ✅ Modular Code Architecture
|
|
60
|
+
- Removed module-level code execution
|
|
61
|
+
- Created proper class structures
|
|
62
|
+
- Added comprehensive imports (`builtins` fix)
|
|
63
|
+
|
|
64
|
+
### 5. ✅ Enhanced Configuration Management
|
|
65
|
+
- Platform-specific config directories
|
|
66
|
+
- JSON-based parameter storage
|
|
67
|
+
- Automatic directory creation
|
|
68
|
+
|
|
69
|
+
### 6. ✅ Improved Path Handling
|
|
70
|
+
- Safe path operations with error handling
|
|
71
|
+
- Automatic creation of output directories
|
|
72
|
+
- Configurable save locations for images and logs
|
|
73
|
+
|
|
74
|
+
### 7. ✅ Testing Framework
|
|
75
|
+
- Created comprehensive test suite:
|
|
76
|
+
- `minimal_test.py` - Non-interactive testing
|
|
77
|
+
- `test_myplot.py` - Full functionality tests
|
|
78
|
+
- `simple_test.py` - Basic usage test
|
|
79
|
+
|
|
80
|
+
### 8. ✅ Package Configuration
|
|
81
|
+
Updated `pyproject.toml`:
|
|
82
|
+
```toml
|
|
83
|
+
[project]
|
|
84
|
+
name = "myplot"
|
|
85
|
+
version = "0.1.0"
|
|
86
|
+
description = "Uniform plotting module for matplotlib with automatic font detection"
|
|
87
|
+
|
|
88
|
+
[build-system]
|
|
89
|
+
requires = ["hatchling"]
|
|
90
|
+
build-backend = "hatchling.build"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Key Features Added
|
|
94
|
+
|
|
95
|
+
### 1. **Platform-Aware Font Search**
|
|
96
|
+
```python
|
|
97
|
+
def get_font_search_paths():
|
|
98
|
+
"""Get platform-specific font search paths."""
|
|
99
|
+
system = platform.system()
|
|
100
|
+
paths = []
|
|
101
|
+
# ... platform-specific logic
|
|
102
|
+
return paths
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. **Enhanced Font Detection with Family Name Fix**
|
|
106
|
+
```python
|
|
107
|
+
def find_source_han_serif_font():
|
|
108
|
+
"""Find Source Han Serif font across multiple search paths."""
|
|
109
|
+
# Comprehensive search with multiple font variants
|
|
110
|
+
# Returns the actual font file path
|
|
111
|
+
|
|
112
|
+
def setup_font_properties():
|
|
113
|
+
"""Setup matplotlib font properties if Source Han Serif is found."""
|
|
114
|
+
# Force register font and set correct family name
|
|
115
|
+
# Uses 'Source Han Serif' (not 'Source Han Serif SC')
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 4. **Enhanced Decorator**
|
|
119
|
+
```python
|
|
120
|
+
def myplot(figsize=(4.8, 3.6), save=True, log=True, savename='', config_dir=None):
|
|
121
|
+
"""Decorator with platform-specific path handling."""
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 5. **Utility Functions**
|
|
125
|
+
- Radian formatter (`radFormatter`)
|
|
126
|
+
- Degree formatter (`degFormatter`)
|
|
127
|
+
- Radian locator (`radLocator`)
|
|
128
|
+
- Font discovery utilities
|
|
129
|
+
|
|
130
|
+
## Testing Results
|
|
131
|
+
|
|
132
|
+
### ✅ Successful Tests
|
|
133
|
+
- **Font Detection**: ✓ Found Source Han Serif correctly
|
|
134
|
+
- **Module Import**: ✓ All imports successful
|
|
135
|
+
- **Utilities**: ✓ All formatters working
|
|
136
|
+
- **Plot Generation**: ✓ Generated test plots successfully
|
|
137
|
+
- **Directory Creation**: ✓ Auto-created appropriate directories
|
|
138
|
+
|
|
139
|
+
### ⚠️ Expected Warnings
|
|
140
|
+
- Multiple "findfont" warnings are normal - matplotlib tries fonts before configuration
|
|
141
|
+
- Non-interactive backend warning when running in headless environments
|
|
142
|
+
|
|
143
|
+
## Usage Examples
|
|
144
|
+
|
|
145
|
+
### Basic Usage
|
|
146
|
+
```python
|
|
147
|
+
from myplot import myplot, plt, np
|
|
148
|
+
|
|
149
|
+
@myplot()
|
|
150
|
+
def my_plot():
|
|
151
|
+
x = np.linspace(0, 10, 100)
|
|
152
|
+
plt.plot(x, np.sin(x))
|
|
153
|
+
plt.xlabel('x')
|
|
154
|
+
plt.ylabel('sin(x)')
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Custom Configuration
|
|
158
|
+
```python
|
|
159
|
+
@myplot(figsize=(8, 6), save=True, log=True)
|
|
160
|
+
def custom_plot():
|
|
161
|
+
# Your plotting code here
|
|
162
|
+
pass
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Using Utilities
|
|
166
|
+
```python
|
|
167
|
+
from myplot import myUtilities
|
|
168
|
+
|
|
169
|
+
# Use custom formatters
|
|
170
|
+
ax.xaxis.set_major_formatter(myUtilities.radFormatter())
|
|
171
|
+
ax.xaxis.set_major_formatter(myUtilities.degFormatter())
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Directory Structure Created
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
myplot/
|
|
178
|
+
├── __init__.py # Main module
|
|
179
|
+
└── README.md # Documentation
|
|
180
|
+
|
|
181
|
+
Test Files:
|
|
182
|
+
├── minimal_test.py # Non-interactive tests
|
|
183
|
+
├── test_myplot.py # Full tests
|
|
184
|
+
├── simple_test.py # Basic tests
|
|
185
|
+
└── MYPLOT_REVISION.md # This documentation
|
|
186
|
+
|
|
187
|
+
Generated Outputs:
|
|
188
|
+
├── minimal_test_plot.png
|
|
189
|
+
├── test_radian_formatter.png
|
|
190
|
+
├── test_degree_formatter.png
|
|
191
|
+
└── test_plot.png (saved to platform-specific location)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Benefits Achieved
|
|
195
|
+
|
|
196
|
+
1. **Cross-Platform Compatibility**: Works on Windows, macOS, Linux
|
|
197
|
+
2. **Robust Font Detection**: Finds Source Han Serif from multiple locations
|
|
198
|
+
3. **Reusable Module**: Can be imported and used in other projects
|
|
199
|
+
4. **Professional Structure**: Proper Python package with documentation
|
|
200
|
+
5. **Comprehensive Testing**: Multiple test scenarios
|
|
201
|
+
6. **Flexible Configuration**: Platform-specific settings
|
|
202
|
+
7. **Automatic Path Handling**: No manual directory management needed
|
|
203
|
+
|
|
204
|
+
## Installation Instructions
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Install dependencies
|
|
208
|
+
pip install matplotlib numpy
|
|
209
|
+
|
|
210
|
+
# For development mode (optional)
|
|
211
|
+
pip install hatch
|
|
212
|
+
|
|
213
|
+
# Run tests
|
|
214
|
+
python minimal_test.py
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Future Enhancements (Optional)
|
|
218
|
+
|
|
219
|
+
1. Add support for more font families
|
|
220
|
+
2. Implement theme system for different plot styles
|
|
221
|
+
3. Add export formats beyond PNG
|
|
222
|
+
4. Implement figure style presets
|
|
223
|
+
5. Add support for multi-figure layouts
|
|
224
|
+
|
|
225
|
+
## Recent Fixes (2026-03-12)
|
|
226
|
+
|
|
227
|
+
### Font Family Name Issue
|
|
228
|
+
- **Problem**: matplotlib was using 'Source Han Serif SC' which caused "findfont: Font family not found" warnings
|
|
229
|
+
- **Solution**: Modified `setup_font_properties()` to force register the font and set family name to 'Source Han Serif'
|
|
230
|
+
- **Result**: Chinese characters now display correctly without warnings
|
|
231
|
+
|
|
232
|
+
### Additional Improvements
|
|
233
|
+
- Added `myparams.font` property for direct font access
|
|
234
|
+
- Enhanced font detection to check multiple variants and fallback strategies
|
|
235
|
+
- Created comprehensive test scripts for verification
|
|
236
|
+
|
|
237
|
+
## Summary
|
|
238
|
+
|
|
239
|
+
The original `_myplot.py` script has been completely transformed into a professional, reusable Python module that addresses all identified limitations while maintaining backward compatibility. The module now provides robust font detection, cross-platform support, and a clean API for creating publication-quality plots with consistent formatting.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
*Created: 2026-03-10*
|
|
243
|
+
*Version: 0.1.0*
|
|
244
|
+
*Status: Production Ready*
|
myplot-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: myplot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A uniform plotting module for matplotlib with automatic font detection
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
7
|
+
Requires-Dist: numpy>=1.20.0
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# MyPlot
|
|
11
|
+
|
|
12
|
+
A uniform plotting module for matplotlib with automatic font detection and cross-platform support.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Uniform Formatting**: Consistent plot styling across all your projects
|
|
17
|
+
- **Automatic Font Detection**: Finds and configures Source Han Serif font for Chinese characters
|
|
18
|
+
- **Cross-Platform Support**: Works on Windows, macOS, and Linux
|
|
19
|
+
- **Easy to Use**: Simple decorator interface for creating publication-quality plots
|
|
20
|
+
- **Built-in Utilities**: Radian/degree formatters and other plotting utilities
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from myplot import myplot, plt, np
|
|
32
|
+
|
|
33
|
+
@myplot()
|
|
34
|
+
def simple_plot():
|
|
35
|
+
x = np.linspace(0, 10, 100)
|
|
36
|
+
plt.plot(x, np.sin(x))
|
|
37
|
+
plt.xlabel('x')
|
|
38
|
+
plt.ylabel('sin(x)')
|
|
39
|
+
plt.title('Simple Plot')
|
|
40
|
+
|
|
41
|
+
simple_plot()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Advanced Usage
|
|
45
|
+
|
|
46
|
+
### Custom Figure Size
|
|
47
|
+
```python
|
|
48
|
+
@myplot(figsize=(8, 6))
|
|
49
|
+
def large_plot():
|
|
50
|
+
# Your plotting code here
|
|
51
|
+
pass
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Save Plots Automatically
|
|
55
|
+
```python
|
|
56
|
+
@myplot(save=True, log=True)
|
|
57
|
+
def save_plot():
|
|
58
|
+
# Plot will be saved automatically
|
|
59
|
+
pass
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Using Utilities
|
|
63
|
+
```python
|
|
64
|
+
from myplot import myUtilities
|
|
65
|
+
|
|
66
|
+
ax.xaxis.set_major_formatter(myUtilities.radFormatter())
|
|
67
|
+
ax.xaxis.set_major_locator(myUtilities.radLocator(np.pi/4))
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Requirements
|
|
71
|
+
|
|
72
|
+
- Python 3.8+
|
|
73
|
+
- matplotlib >= 3.5.0
|
|
74
|
+
- numpy >= 1.20.0
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT License
|
myplot-0.1.0/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# MyPlot
|
|
2
|
+
|
|
3
|
+
A uniform plotting module for matplotlib with automatic font detection and cross-platform support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Uniform Formatting**: Consistent plot styling across all your projects
|
|
8
|
+
- **Automatic Font Detection**: Finds and configures Source Han Serif font for Chinese characters
|
|
9
|
+
- **Cross-Platform Support**: Works on Windows, macOS, and Linux
|
|
10
|
+
- **Easy to Use**: Simple decorator interface for creating publication-quality plots
|
|
11
|
+
- **Built-in Utilities**: Radian/degree formatters and other plotting utilities
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install -e .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from myplot import myplot, plt, np
|
|
23
|
+
|
|
24
|
+
@myplot()
|
|
25
|
+
def simple_plot():
|
|
26
|
+
x = np.linspace(0, 10, 100)
|
|
27
|
+
plt.plot(x, np.sin(x))
|
|
28
|
+
plt.xlabel('x')
|
|
29
|
+
plt.ylabel('sin(x)')
|
|
30
|
+
plt.title('Simple Plot')
|
|
31
|
+
|
|
32
|
+
simple_plot()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Advanced Usage
|
|
36
|
+
|
|
37
|
+
### Custom Figure Size
|
|
38
|
+
```python
|
|
39
|
+
@myplot(figsize=(8, 6))
|
|
40
|
+
def large_plot():
|
|
41
|
+
# Your plotting code here
|
|
42
|
+
pass
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Save Plots Automatically
|
|
46
|
+
```python
|
|
47
|
+
@myplot(save=True, log=True)
|
|
48
|
+
def save_plot():
|
|
49
|
+
# Plot will be saved automatically
|
|
50
|
+
pass
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Using Utilities
|
|
54
|
+
```python
|
|
55
|
+
from myplot import myUtilities
|
|
56
|
+
|
|
57
|
+
ax.xaxis.set_major_formatter(myUtilities.radFormatter())
|
|
58
|
+
ax.xaxis.set_major_locator(myUtilities.radLocator(np.pi/4))
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Python 3.8+
|
|
64
|
+
- matplotlib >= 3.5.0
|
|
65
|
+
- numpy >= 1.20.0
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT License
|