Comments (3)
Apparently pylustrator does not work when using the pylab * import.
I would strongly recommend to import matplotlib and numpy directly with "import matplotlib.pyplot as plt" and "import numpy as np" as it makes the code more readable. For example if you use "max" it is not clear if you are using the builtin function max or the numpy function max, as your approach silently overwrote it.
See also the warning box here:
https://matplotlib.org/stable/api/index.html?highlight=pylab#module-pylab
As pylustrator overloads the plt.figure and plt.show commands, it cannot work if you have already imported them directly without still being in the namespace of a module.
Therefore, you need to write it like this when using pylustrator.
import matplotlib.pyplot as plt
import numpy as np
π = np.pi
import pylustrator
pylustrator.start()
t = np.linspace(0, 1)
x = np.sin(2 * π * t)
plt.plot(t, x)
plt.show()
from pylustrator.
if you want to keep your code like this, you can alternatively just use plt.show() for opening the pylustrator and leave the rest as it is. As just this is the crucial part.
So this also works, although I would recommend against importing with *
from matplotlib.pylab import *
π = pi
import pylustrator
pylustrator.start()
t = linspace(0, 1)
x = sin(2 * π * t)
plot(t, x)
import matplotlib.pyplot as plt
plt.show()
from pylustrator.
Oh, thanks! It does work! 🎉
Thanks for the recommendation as well, but I'd rather use a calculator without the need to tell it where to find its functions. If I do write code, then yes, I use namespaces. If I do maths, then no, it just bogs down the thinking.
Finally, not sure this is a bug, but the button strings are quite illegible.
Also, I believe some y
's are missing.
from pylustrator.
Related Issues (20)
- Feature request: loading and editing pickle-dumped figures HOT 2
- Error when importing HOT 2
- Preparing metadata error when doing pip install HOT 2
- Make the panels resizeable HOT 4
- Crash when resizing the main Figure HOT 7
- Is the load function able to load pdf figures? HOT 2
- seems to be broken out of the box... HOT 8
- `ImportError: cannot import name 'SubFigure' from 'matplotlib.figure`' HOT 3
- removal of auto save popup window HOT 5
- Misc `not found`, `not in list` errors HOT 2
- Better test coverage
- Can not Start Pylustrator HOT 8
- A tool to create insets
- `linestyle` should also accept tuples an not just strings HOT 1
- ModuleNotFoundError: No module named 'matplotlib.axes._subplots' HOT 2
- pylustrator not working in google colab HOT 2
- Issue with saving via pylustrator's Save As... menu on Windows HOT 1
- Prevents relative import of data to plot HOT 2
- Combining seaborn and matplotlib plots HOT 1
- Location of the dashed box to move the subplot is shifted from the original subplots HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylustrator.