I am trying to build an interactive Pygal worldmap. I posted my code below, but any ideas why the numbers are not showing up when I hover over the map? Thanks!
import pygal
wm = pygal.maps.world.World()
wm.title = "Americas"
wm.add('North America',{'ca': 320161819,'mx': 115405161,'us': 301018101})
wm.render_to_file('americas.svg')
Related
I am trying to plot the contour of an image and get it overlaid over the original image but without filling, I would like it to appear as an edge contour instead of a filled contour like the attached picture.
I used this command but the problem is when I used the LabelOverlay function the image contrast changed! while I need to keep the same image intensity, any idea of how to solve it? The code is : sitk_show(SimpleITK.LabelOverlay(imgOriginal1, SimpleITK.LabelContour(imgOriginal2)))
I would encourage you to check out platipy - a software package for which I am a developer and have built some nice tools for visualisation.
Here is an example:
import SimpleITK as sitk
from platipy.imaging import ImageVisualiser
img = sitk.ReadImage("./CT.nii.gz")
mask = sitk.ReadImage("./MASK_LUNGS.nii.gz")
vis = ImageVisualiser(img)
vis.add_contour(mask)
fig = vis.show()
fig.savefig("example.jpeg", dpi=300)
This tool is highly customisable, check out the documentation on Github :-)
I would like to plot some images I webscraped from a website, and I want to make a interactive plot in Jupyter notebook/Colab where the interactivity is being able to click on the images, which will get you to the url where I got the image.
I get the images and have them as follows:
im = Image.open(requests.get(df_info['Img'][i], stream=True).raw)
Then I found some code using ImageTk that looks like the following. But the problem is when I set the command option, im feeding a function open that requires an argument (the url)
from PIL import ImageTk
import webbrowser
root = Tk()
canvas = Canvas(root, width=600, height=600)
canvas.pack()
def open(url):
webbrowser.open(url)
img_file = Image.open(requests.get(df_info['Img'][0], stream=True))
img_file = img_file.resize((150, 150))
img = ImageTk.PhotoImage(img_file)
b1 = Button(canvas,image=img,command=open).pack()
root.mainloop()
I am not sure I have to use this ImageTk framework, either. It would be great if there was a way to just use matplotlib functions as well. But the key is to have that clickability on the pictures in the Jupyter notebook.
Could someone please help me?
Here is the code:
import seaborn as sns
tips = sns.load_dataset("tips")
p1 = sns.countplot(x='sex',data=tips)
No matter what size adjustments I try to make by adding the height parameter or aspect, this is how it appears in Jupyter. Any idea how to change this? I am following a tutorial and in the video tutorial it appears fine, just not for me.
I was translating a Java sketch to a Python sketch in Processing. It is using the P3D engine and it is not showing anything in the window while it is showing what I want in Java mode. When I run it just shows a blank black window instead of a grid. I can change its background color but I can not draw in the shapes or something window. Please help me! And I can not share its code as it is not an open source project.
It was my fault. It was a mistake in the code. I was making the grid using for loop and the variables that were needed for for loop were not defined properly it was not giving an error because the value of variables was 0. Sorry for wasting your time. Enjoy!
I would like to compare multiple conditions of an altair (ultimately vega-lite) layered plot. The perfect solution would be to facet/trellis the plot so I can see the different conditions side by side. Unfortunately I cannot figure out how to give the command to plot the different conditions.
Here is my attempt to implement my idea based on the example for layered plots:
(https://github.com/ellisonbg/altair/blob/master/altair/notebooks/07-LayeredCharts.ipynb)
import pandas as pd
import numpy as np
data = pd.DataFrame({'x':np.random.rand(10), 'y':np.random.rand(10), 'z':['a', 'b']*5})
chart = LayeredChart(data)
chart += Chart().mark_line().encode(x='x:Q', y='y:Q', column='z:Q')
chart += Chart().mark_point().encode(x='x:Q', y='y:Q', column='z:Q')
chart
When compared with the example I added the column 'z' with the two conditions, and the two column statements in the Chart definitions.
This solution generates seemingly good Vega-lite code, but no plot. Alternatively I tried "chart = LayeredChart(data).encode(column='z:Q')" but I then got the error 'LayeredChart' object has no attribute 'encode'
I am wondering whether it is possible to facet (trellis) layered plots at all and whether it will be possible in future Vega-Lite releases.
I am using jupyter with Anaconda
Layering is only experimentally supported in the current release of Vega-Lite and Altair, and I believe you've hit one of the unsupported aspects. This should be addressed in the Vega-Lite 2.0 release (and associated Altair release) later this spring.