You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right, as promised here, I have a few suggestions:
First things first, this is a fairly well-structured demonstration - well done.
Ploty and Bokeh
To be fair, you have highlighted that libraries such as Bokeh and Plotly exist, but that you're not sufficiently accustomed to them. Before I read the description, my first impression was that why are these not included? Now there are plenty of important features offered by these libraries that are missing from MatPlotLib, which itself is the backbone of most desktop GUI libraries. I'll discuss a couple of them here:
WebGL
Surface plots (3D)
The most important feature of Plotly in my opinion is that it offers isosurface plotting (3D surface) through surface triangulation. This is not offered by MatPlotLib. The immediate alternative is Mayavi, which relies upon VTK, the renowned C++ library. It is a nightmare to compile and install, and its support for Python 3 is floppy at best.
SVG and WebGL
Plotly leverages GPU through WebGL for isosurface plotting. Both Plotly and Bokeh offer WebGL and SVG engines for 2D plots, too (Plotly SVG v WebGL, Bokeh WebGL). This means that fairly complex and crowded 2D plots (or lives ones) can be drawn with relative ease through WebGL. They are also fairly watertight in terms of JavaScript security (I have reviewed some of the code, and I know a few other security guys who've provided feedback to Plotly).
As good as WebGL is, it goes so far before the browser starts complaining. In such cases, I recommend VisPy. Now this is a somewhat advanced solution, since it might require some OpenCL / C programming experience. It is made slightly less complex through GlumPy, a fairly well-developed fork. The both provide Jupyter interfaces.
PyQtGraph
PyQtGraph is another alternative, which also relies on OpenCL, but provides nice Python wrappers. It takes advantage of Qt and Tkinter GUIs as well as providing a decent Jupyter interface. It is a well-designed GPU-enabled alternative to MatPlotLib for plots that are not primarily intended for publication (although no one stops you from publishing the results), and are meant to be used for live analyses. I specially like PyQtGraph because I won't have to explain what 50 lines of C-resembling OpenCL code does in the middle of my Python code (stored as string variable, no less).
Coding Style
Whilst I appreciate the fact that you have been trying to accommodate the presentation for those who may be familiar with R, I firmly believe that new programmers would really benefit from learning, and sticking to Python Coding Convention, also known as PEP8. So it might be a good idea to introduce it somewhere, and may be even modify some of the examples such that they follow PEP8 recommendations. Of course it's not holy scripture, and can be broken if and when deemed necessary... just a simple suggestion.
I would also encourage people to stick to the latest release of Python (which is 3.6.1 at the moment) as it means they would enjoy an interpreter that's faster, and offers a lot more (e.g. async functions, dot multiplications using @, f-strings, ...). Plus, support for Python 2.7 will officially stop in 2020, and many well-known libraries have already started dropping it. I personally haven't written a single line of code with Python 2.7 compatibility in mind since 2015.
Also, connecting functions to each other using dot operators, writing prolonged lines of code, doing several operations in one line, and extending one line across multiple lines (often using parentheses or backslash), whilst appealing to some programmers and extensively used in languages such as Java or other JVM language, is against Python best practices and at least in my opinion, is a recipe to produce error-prone code - especially for novice / amateur programmers. And example of this is:
(sns
.FacetGrid(mpg, hue="class", size=10)
.map(plt.scatter, "displ", "hwy")
.add_legend()
.set(
title="Engine Displacement in Liters vs Highway MPG",
xlabel="Engine Displacement in Liters",
ylabel="Highway MPG"
));
Now I know that Seaborn does things like this in its official docs, but then examples shouldn't really be taken as they are (again, this is more of a suggestion than anything else). I would reformat this code as follows:
f_grid=FacetGrid(mpg, hue="class", size=10)
ax=gca()
grid_map=f_grid.map(ax.scatter, "displ", "hwy")
grid_map.add_legend()
ax.set_title("Engine Displacement in Liters vs Highway MPG")
ax.set_xlabel("Engine Displacement in Liters")
ax.set_ylabel("Highway MPG")
Not only is this 2 lines shorter than the alternative, it's easier to debug because the interpreter can pinpoint where the source of an error is should one occur.
Conclusion
This is a great start, and has the potential to become a comprehensive reference and I shall be happy to assist you in any way I can. I'm fairly experienced in data visualisation, and Python is my primary language (and has been for over 10 years). So feel free to throw things my way if you want.
Thank you for doing this, and sorry for the lengthy feedback.
Again, I'll be happy to do what I can to help.
The text was updated successfully, but these errors were encountered:
Right, as promised here, I have a few suggestions:
First things first, this is a fairly well-structured demonstration - well done.
Ploty and Bokeh
To be fair, you have highlighted that libraries such as Bokeh and Plotly exist, but that you're not sufficiently accustomed to them. Before I read the description, my first impression was that why are these not included? Now there are plenty of important features offered by these libraries that are missing from MatPlotLib, which itself is the backbone of most desktop GUI libraries. I'll discuss a couple of them here:
WebGL
Surface plots (3D)
The most important feature of Plotly in my opinion is that it offers isosurface plotting (3D surface) through surface triangulation. This is not offered by MatPlotLib. The immediate alternative is Mayavi, which relies upon VTK, the renowned C++ library. It is a nightmare to compile and install, and its support for Python 3 is floppy at best.
SVG and WebGL
Plotly leverages GPU through WebGL for isosurface plotting. Both Plotly and Bokeh offer WebGL and SVG engines for 2D plots, too (Plotly SVG v WebGL, Bokeh WebGL). This means that fairly complex and crowded 2D plots (or lives ones) can be drawn with relative ease through WebGL. They are also fairly watertight in terms of JavaScript security (I have reviewed some of the code, and I know a few other security guys who've provided feedback to Plotly).
Interactivity
Bokeh offers excellent features for interactive plots; synchronous selections, data-dependent plots, and linked plots are few examples of such features.
GPU on Desktop
VisPy and GlumPy
As good as WebGL is, it goes so far before the browser starts complaining. In such cases, I recommend VisPy. Now this is a somewhat advanced solution, since it might require some OpenCL / C programming experience. It is made slightly less complex through GlumPy, a fairly well-developed fork. The both provide Jupyter interfaces.
PyQtGraph
PyQtGraph is another alternative, which also relies on OpenCL, but provides nice Python wrappers. It takes advantage of Qt and Tkinter GUIs as well as providing a decent Jupyter interface. It is a well-designed GPU-enabled alternative to MatPlotLib for plots that are not primarily intended for publication (although no one stops you from publishing the results), and are meant to be used for live analyses. I specially like PyQtGraph because I won't have to explain what 50 lines of C-resembling OpenCL code does in the middle of my Python code (stored as string variable, no less).
Coding Style
Whilst I appreciate the fact that you have been trying to accommodate the presentation for those who may be familiar with R, I firmly believe that new programmers would really benefit from learning, and sticking to Python Coding Convention, also known as PEP8. So it might be a good idea to introduce it somewhere, and may be even modify some of the examples such that they follow PEP8 recommendations. Of course it's not holy scripture, and can be broken if and when deemed necessary... just a simple suggestion.
I would also encourage people to stick to the latest release of Python (which is 3.6.1 at the moment) as it means they would enjoy an interpreter that's faster, and offers a lot more (e.g. async functions, dot multiplications using @, f-strings, ...). Plus, support for Python 2.7 will officially stop in 2020, and many well-known libraries have already started dropping it. I personally haven't written a single line of code with Python 2.7 compatibility in mind since 2015.
Also, connecting functions to each other using dot operators, writing prolonged lines of code, doing several operations in one line, and extending one line across multiple lines (often using parentheses or backslash), whilst appealing to some programmers and extensively used in languages such as Java or other JVM language, is against Python best practices and at least in my opinion, is a recipe to produce error-prone code - especially for novice / amateur programmers. And example of this is:
Now I know that Seaborn does things like this in its official docs, but then examples shouldn't really be taken as they are (again, this is more of a suggestion than anything else). I would reformat this code as follows:
followed by:
Not only is this 2 lines shorter than the alternative, it's easier to debug because the interpreter can pinpoint where the source of an error is should one occur.
Conclusion
This is a great start, and has the potential to become a comprehensive reference and I shall be happy to assist you in any way I can. I'm fairly experienced in data visualisation, and Python is my primary language (and has been for over 10 years). So feel free to throw things my way if you want.
Thank you for doing this, and sorry for the lengthy feedback.
Again, I'll be happy to do what I can to help.
The text was updated successfully, but these errors were encountered: