I was trying to use violin chart in Bokeh but unable to find this type of chart. So, I use seaborn library to build the violin chart and use it into bokeh.
Code:
import seaborn as sns
from bokeh import mpl
import pandas as pd
df = pd.DataFrame({"x": [1,1,1,2], "y":4,5,8,9})
sns.violinplot(x="x", y="y", data=df)
plot = mpl.to_bokeh()
plot.plot_width = 500
plot.plot_height = 300
Now, I want to add tooltip on bokeh converted chart from seaborn. I googled a lot but not able to find a way.
This is no longer possible, at least in this form. The MPL compatibilityin bokeh, including mpl.to_bokeh() was deprecated and completely removed some time ago. You might have a look at Holoviews which is a very high level API built on top of Bokeh that I believe just added a Violin plot.
Related
I have some report, here is a sample to repeat:
In[1]:import pandas as pd
import numpy as np
In[2]:import seaborn as sns
sns.set_theme(style="darkgrid")
# Load an example dataset with long-form data
fmri = sns.load_dataset("fmri")
# Plot the responses for different events and regions
sns.lineplot(x="timepoint", y="signal",
hue="region", style="event",
data=fmri)
Out[2]:
In[3]:fmri
Out[3]:
How can I upload my report from jupyter notebook to google sheets, because I have a task to hand over the work in the file "https://docs.google.com/spreadsheets/...." but there were no restrictions on what is better to do, I saw this only when I tried to upload a link to my github in the google form, now I think how can I convert my results, one of the options is to insert screenshots of my report into a file in google sheets, but maybe there is a better option
I am a trying video processing on google colab. My code read the video and break it into frames and after the processing on the frame I want to display the video as frames are processed. Like what cv2.imshow does (on local computer). But cv2.imshow gives error in colab so as it suggested I used cv2_imshow using from google.colab.patches import cv2_imshow . It is displaying the frames but in an column(like separate images) but replacing the previous displayed. Here is my colab link: https://colab.research.google.com/drive/1RUOGahcGngTWG9nBoisrsPzCLQ1Jq88v?usp=sharing
You can see the output at the end of the page where multiple images are.
Any help is really appreciated :)
try:
from google.colab.patches import cv2_imshow
from IPython.display import clear_output
from time import sleep
clear_output()
cv2_imshow(img)
sleep(0.1)
it's far from perfect (since there are some frame drops for some reason), but that's the closest thing I could find.
I am trying to use PIL to show an image. I know that I can use other modules to do that. I am working on google colab. But I can't figure out why PIL is not showing output image.
% matplotlib inline
import numpy as np
import PIL
im=Image.open('/content/drive/My Drive/images-process.jpeg')
print(im.width, im.height, im.mode, im.format, type(im))
im.show()
output: 739 415 RGB JPEG < class 'PIL.JpegImagePlugin.JpegImageFile'>
Instead of
im.show()
Try just
im
Colab should try to display it on its own. See example notebook
Use
display(im)
instead of im.show() or im.
When using these options after multiple lines or in a loop, im won't work.
After you open an image(which you have done using Image.open()), try converting using im.convert() to which ever mode image is in then do display(im)
It will work
For example, given this graph:
gremlin> graph = TinkerFactory.createModern() (1)
==>tinkergraph[vertices:6 edges:6]
gremlin> g = graph.traversal(standard()) (2)
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().has('name','marko').out('knows').values('name') (3)
I want to print out a PNG file for this graph from the console. The documentation doesn't say how to do it. Thanks in advance.
TinkerPop doesn't provide graph visualization options directly. The best you can do is either:
Use the Gephi plugin to visualize your graph and then save that visualization to an image.
Export your graph to GraphML and then import it into a visualization tool, like Gephi, Cytoscape, etc. and then export an image generated from there.
If you use Python at all, the networkx and matploitlib libraries can read a GraphML file and render it. I have used this in a Python Notebook with Gremlin Python running where I extracted a subgraph to GraphML and rendered it using Python.
The code would be along the lines of:
import matplotlib
import matplotlib.pyplot as plt
import networkx as nx
G = nx.parse_graphml(mygraph)
label = nx.get_node_attributes(G, "code")
plt.figure(figsize=(11,11))
nx.draw(G, node_color="#ffaa00",node_size=1200,labels=label,arrows=False)
Apologies in advance if my Python is ugly I'm more of a Ruby and Groovy guy :-)
I have been trying to save statistical graphs (boxplot, barchart, histogram etc) of some random data generated using Seaborn into LaTeX without saving them into a file first. I use \sageplot[width=8cm][png]{(Python_Graphics_Format)} from SageTex package to do this.
For example, when I draw a Box Plot using Seaborn it generates all kinds of format (name.gcf(), name.show(), name.plot(), name.draw() etc) but Graphics format. Is there any way to do this without using 'name.savefig()' or likes?
Why is it important for me?
I would like to generate a list of predefined sage functions in a separate tex file together with bunch of randomly generated data and input them on top of my TeX code after \maketitle. This way, I will be able to generate multiple problems of similar nature and upload them to the online HW system Ximera.
Here is a code that I took from stackoverflow:
import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x=tips["total_bill"])
Your help is most appreciated.