Displaying two different chart types in a single browser (plotly with python) - plotly-python

I am using plotly to display a line chart and a pie chart using python, but when i run the code it opens the charts in two separate browsers. I was wondering how I can get both charts to open in one single browser.
The code for both works but separately on different browsers. I tried using the plotly.subplots library but this is what it prints:
ValueError: Trace type 'pie' is not compatible with subplot type 'xy'
at grid position (2, 1)
See the docstring for the specs argument to plotly.subplots.make_subplots
for more information on subplot types

Did you try using plotly.graph_objects.Pie?

Related

Display dataframe in a separate panel in Jupyter Lab

I would like to display my dataframe in a seperate panel/window in Jupyter Lab. Currently, I can open .csv files in a separate window (which helps write code side-by-side to the data I'm working with), but I want to do this with active dataframes as well.
Is there a way to do this native to Jupyterlab, similar to how it is done in MATLAB? If not, what is the best way to do it otherwise?
Yes. There are several ways:
Display the data frame in a cell output, then right-click on the output and select Create New View for Output
Use jupyterlab-sidecar package:
from sidecar import Sidecar
sc = Sidecar(title='My dataframe')
with sc:
display(df)
(JupyterLab 3.3+) Activate the visual debugger, go to variables list, hover over the variable and click on loop icon.
You can combine approach (1) or (2) with IPython widgets to create an interactive explorer for larger data frames, such as this pandas_explorer snippet. There are other, more complete, interactive explorers which you can embed in a sidecar or move to the new output, for example ipydatagrid.

How to save a figure with multiple overlapping plots?

I am plotting multiples signals overlapping in one figure using matplotlib and then saving it in pdf/eps using matplotlib.pyplot.savefig, the problem is that when I try to insert the figure in a pdf-latex file, it takes like 1.5 min to load because it starts rendering every plot. Is there any way to properly save or create these plots in one figure?
The final pdf works perfectly when I use preview on macOS, regularly when I use edge or chrome navigators and it is a disaster if I use adobe-reader. I am looking for a multiplatform solution.

How to increase the font size/ better render Pandas dataframes in Jupyter Notebooks opened in VS Code?

Is there a way to change how Pandas dataframes are rendered in output cells of Jupyter Notebooks opened in VS Code? By default, the font of the dataframe output is small, regardless of my VS code settings (see 1). In addition, I'd like for the dateframes to render more like the default rendering in native Jupyter notebook opened in a browser (see 2). Does anyone know how to make VS code change the dataframe rendering. Is there something I need to change in settings?
Notebook in VS Code:
Notebook in Chrome:
Edit: Using print(df) only increases the font size to match my font settings, but doesn't change the appearance.
Maybe these two new settings in vscode v1.67 will help:
notebook.outputFontSize, "Font size for plain text outputs. When set to 0 #editor.fontSize# is used."
notebook.outputFontFamily, "The font family for plain text output of notebook cells. When set to empty, the #editor.fontFamily# is used."
from https://github.com/microsoft/vscode/pull/147321/commits/51ab78f535d8537e031e1ae77cac678ae22b0249

How to interact with a plot/figure in Julia

I'm (ultra) new to Julia and I'm trying to figure out how to interact with a plot. To be more specific, currently I use Pyplot do display different kinds of data (in one instance I just plot multiple curves via plot() and in the other I plot the values of a 2d array as heatmaps via imshow()).
I want to be able to click on these images and handle the clicking as event in the code. Upon searching I only find old posts that say "this is currently not featured".
Does anyone have suggestions on where to look/ what to do?
Thanks in advance.

Matplotlib plot a series of interactve plots one plot at a time

I'm trying to plot a series of plots one plot at a time. When a plot is displayed I want to be able to interact with it (i.e. zoom, pan, etc.) and wait until I'm done before the next plot is displayed.
I saw the post matplotlib plot and then wait for raw input, but I couldn't get it to work.
I'm using Spyder and Python 3.4.
Below is the code snippet of what I'd like to do. However the plots seem to get blocked by the waiting for input.
for i in range(4):
plt.figure()
plt.plot([x for x in range(100)],'x')
plt.show(block=False)
a=input('next plot')
If you are looking for interactive plots in Python, you might want to take a look at the Charts library. It enables you to use the excellent Highcharts javascript library to make beautiful and interactive plots. Highcharts uses the HTML svg tag so all your charts are actually vector images.
Some features:
Vector plots which you can download in .png, .jpg and .svg formats so you will never run into resolution problems
Interactive charts (zoom, slide, hover over points, ...)
Usable in an IPython notebook
Explore hundreds of data structures at the same time using the asynchronous plotting capabilities.
Disclaimer: I'm the developer of the library
I believe this is resolved in the recent matplotlib v.2.0.0 release. At least it resolved this problem for me.