Hi, most likely it is due to different version of Pythonista matplotlib compared to the version you use in your computer or the version used to produce the image of the example. Pythonista matplotlib version is 1.4.0.
However for 3D graphs (xyz) I would not use Pythonista, for them I'd use other apps (like for example Visual Math 4D, I apologize for mentioning it in this forum).
@twinsant Hi, I use Pythonista as a general programming tool that expands the ios capabilities in a single app (math, graphics, file/folder management, ... with a powerful language as Python).
About your task (teaching coding) it is not very easy to answer you precisely because it involves complex topics like teaching (teaching is not easy) and coding (a huge world). I think nowadays a lot of students want to know practical problems because they are immersed in a strongly digital world without knowing the hystory and the complexity about programming.
Anyway I try to list a series of general ideas or questions:
- Would you use Pythonista alone or your students can use Pythonista to test or write codes?
- Would you use Pythonista (with your iPad or iPhone) linked to a big display in order to show in classroom what you want to teach?
- A way could be share your lessons by linking your idevice with a big display in front of students (I don't know if it is possible with any TV/LCD display), perform dynamic lessons with questions, wait for answers from students, create different situations about the problem you want to solve with a programming approach, give students opportunities to do exercises about your lessons (all based on your creativity): if they have not Pythonista on their devices (Android?) you could ask them to write, after your lesson, some little pieces of code by hand at home that perform a specific task and that can be add in the main program. The next day you could add students's solutions to the main program and show the effects by running or debugging the main code with students solutions.
- I think it is better to start with practical problems (in real world) that can be solved or studied with a programming approach. It is better if you start with simple problems like for example: find with programming if a number is prime number, or simulate the dices throwing to perform statistics about number of times the number N comes out and compare it with probability theory (if the students have studied something about probability). Then you could try to solve/study with programming approach something more difficult like for example the simulation of how the rest is calculated and returned in a snacks or drinks distributor with a certain amount of coins inside with minimization of number of coins returned (for example if I want a CNY 8.35 snack and I put inside the machine one coin CNY 10, how to calculate the rest with the minimum number of coins knowing that inside the machine there are X CNY 0.01, Y CNY 0.02, etc...): the problem could be studied in a theoretical way or with a programming approach.
- The best thing for me is that every student has the ability to program with his device when he/she wants, if you use Pythonista then all students should have Pythonista (it is better, but not required in my opinion). And it would be better to have a way for sharing jobs and codes or projects in classroom or at home that is easy to use: I don't know if there are some pure-python libraries that creates a platform for sharing pieces of code for teaching purposes and that can run in Pythonista.
Best luck for you intentions.
Hi @reticulated, I'm quite sure omz is still working on Pythonista because I think it's tremendous (and not very smart) that such an application is abandoned. We should know that he knows this fact (I know he knows this fact).
I'm happy when people help people with ideas, codes, examples, informations.
You are talking about things too advanced for me, but I'm sure you are talking in order to give Pythonista more power.
The nice and curious thing is to understand how to give more power to Pythonista without pretending that is omz to give it (that is without need to compile entire Pythonista for new releases).
The best thing in my opinion is to give omz maximum freedom to decide when to give us new releases of his great app, and in the meantime people could continue to give more power to Pythonista, maybe with plug-ins development.
- to extend functions of code editor with find/replace, reformat, code folding... with one click
- to extend functions of file browser with find/replace for files and folders and content (with regex), zip compression, full properties on files and folders (size, last edited data, if file is editable or not, so I'd like to block some files or folder by editing them, ... )
- to extend functions to link Pythonista to any computer for comfortable development of Pythonista/Python scripts using big pc keyboard (my iphone is little and to use WebIDE) we need a wifi shared, not always available, but maybe with bluetooth could be possible using only pure python libraries or scripts,
- to extend a possible free remote connection service/interface if you want to make calculations that require not-pure python libraries not present in Pythonista (scipy, pandas, etc..) and with a full and complete integration with the app environment (example: my script, to run, needs some scipy functions, ok, I write it in Pythonista and I execute the entire script with Pythonista interpreter, and only the code that requires scipy is executed by the server with full working input-output capabilities),
- to extend internal site-packages folder in order to be able to delete not used pure-python libraries, since we can reinstall them with pip (using StaSH for example).
@twotoed Hi, do not be discouraged, Pythonista is great, it is maintained by one person and for this reason can't be compared to a PC python environment (don't forgive the limits imposed by Apple about a lot of things...).
Anyway, as @dgelessus and @JonB suggested, a good way is to install in Pythonista the library you need, if it is impossible download and extract it in Pythonista site-package folder. Then find, inside the installed lib you want to use, all names of libraries not installable in Pythonista, like scipy, and comment them: you must find alternatives (in most cases you need to search internet for numerical recipes or for pure-python libs).
I know, in python world I'm also frustrated when I must download a big python lib even if I use only 3% of all features available in that lib.
About the lib matplotlib-venn, the only scipy request is, as @JonB pointed, a numerical root solver that is brentq, that you can replace with a similar one Pythonista has in built-in mpmath lib.
A solution using function findroot that you find in mpmath lib (already implemented in Pythonista) is:
- open _math.py in main folder of matplotlib-venn
- comment the scipy importing and adding in place of it: from mpmath import *
- where you find the command:
return brentq(lambda x: circle_intersection_area(r, R, x) - a, R - r, R + r)modify it by writing
return findroot(lambda x: circle_intersection_area(r, R, x) - a, R)where R is the average between 'R-r' and 'R+r' of the brentq function.
- save _math.py
Now you should be able to run the folowing test example that I found in Stackoverflow:
import matplotlib.pyplot as plt from matplotlib_venn import venn3, venn3_circles v = venn3(subsets=(1,1,0,1,0,0,0)) v.get_label_by_id('100').set_text('First') v.get_label_by_id('010').set_text('Second') v.get_label_by_id('001').set_text('Third') plt.title("Not a Venn diagram") plt.show()
@augusto Hi, you don't need to install SageMath in Pythonista, it is impossible. You can use a set of python scripts, that run well in Pythonista, in order to send to the remote server some C or Fortran codes/pieces of code to test them.
In short: with Pythonista you can do a lot of things (trust me, a lot), and a thing that you can do easly with Pythonista is to send some code to a remote python server (SageMathCell, please give credits to Andrey, the main maintainer, for this free service), wait for response and process the output, in order to use it in Pythonista, like a global variable that you can use as you want. You must be online to use the service.
Please follow the instructions in the corresponding thread here. Try by yourself, you must download the last version of sage_interface, extract it in any folder of Pythonista, see what is inside that folder to understand how to send some Fortran code and obtain the output as a printed string or number/array.
If you need more info, please ask in that thread.
For Fortran codes something here.
Obviously you must be online with your Pythonista.
As example of C code that you can edit in Pythonista and run using Pythonista and the remote server is the following:
from sage.misc.cython import compile_and_load C_code = """ def f(int n): return n*n """ module = compile_and_load(C_code) print(module.f(10))
As example of Fortran, the following:
FORTRAN_code = ''' C FILE: FIB1.F SUBROUTINE FIB(A,N) C C CALCULATE FIRST N FIBONACCI NUMBERS C INTEGER N REAL*8 A(N) DO I=1,N IF (I.EQ.1) THEN A(I) = 0.0D0 ELSEIF (I.EQ.2) THEN A(I) = 1.0D0 ELSE A(I) = A(I-1) + A(I-2) ENDIF ENDDO END ''' fortran(FORTRAN_code, globals()) import numpy a = numpy.array(range(10), dtype=float) fib(a, 10) print(a)
There is no reason to code in C or Fortran using Pythonista, but sometimes user wants to test some existing open source codes in these programming
@powersim Hi, have you tried to install it via 'pip install pyephem' with StaSh? To install StaSh, if not installed in Pythonista you use, run the following code:
import requests as r; exec(r.get('http://bit.ly/get-stash').text)
then run the file 'launch_stash.py' installed in the main folder of Pythonista and use pip in the shell.
If the library you are installing depends on not pure python codes like C or Fortran, no way to use it in Pythonista, but if it needs only pure python libraries, the command pip in StaSh works like the one in computer, it installs all the needed dependencies.
The only solution I have in mind to run not pure python libraries with Pythonista is to use a remote python server by adding to a python temporary directory of the server the precompiled library you want, according to the os of the python server (Linux, Windows, ...), and by changing the python sys path so the remote python server can find in the temporary folder all it needs to run your scripts based on precompiled library. Not very comfortable because it is slow (it must download a full precompiled lib every time during independent sessions) but it works.