I am creating a World Map, where you can hover over countries and click on their tooltips to link to a seperate website with more information on them. The problem is, I find the tooltips are too big, and get in the way. How do I resolve this issue?
I tried using the tooltip_font_size command to control it, but it just does not seem to make a difference. I get the same size of the Tooltips and the text inside them no matter what value I put in there. All the tooltip_border_radius command does is change how round the borders of my tooltips are. I am quite lost here, what do I do?
This is the code I have for now, I am excluding the added portion ( myworldmap.add) since it is unnecessary here.
import pygal
myworldmap = pygal.maps.world.World() #Defining our world map
myworldmap.title = 'Our friends origins'
myworldmap.tooltip_font_size = 15 #fontsize control
myworldmap.tooltip_border_radius = 5 #bordersize control
Related
I am brand new to coding and have been trying to figure out how to automatically create Anki cards based off a designated highlighting color in Power Point. I’m struggling to find code that searches for the designated color multiple times if there are many highlighted parts. I also don’t know how to make it switch to the next slide if the designated colors are not found. If anyone is able to help me on this, that would be amazing.
I tried pulling code from people with similar answers but since I am so new I struggle with implementing them.
This is a bit of a stupid problem but I'm using plotly for a 3d Scatter plot, essentially tweaking the Les Miserables plot in the docs, and I've managed to put links to the Wikipedia page for each node in the node labels.
Essentially, I'm replacing this line (in block 6 on that tutorials page): labels.append(node['name'])
with this line:
labels.append('{}'.format(node['name'], node['name']))
Works like a charm! Except that when I hover over the node, the label appears, but then when I go to click the link in the label, the label disappears (because I have oh-so-slightly hovered off of the node).
Like I said, kind of a stupid problem, but I really like the linking in the labels and this makes them almost unusable. Any ideas for how to deal with this (is there a way to set a lag for how quickly the labels disappear when you hover off? can the labels themselves trigger the hover?) would be greatly appreciated!
Here is a first draft example of what I'm working on:
https://plot.ly/~seth127/6
Thanks!
I am using bokeh for plotting. With my current settings, bokeh shows some text and lines kind of blurred (anti-aliased?). This is not really noticeable on my monitor, but on some projectors, especially when doing screenshots and inserting them into presentations, it looks weird.
As requested, a minimum working example:
from bokeh.plotting import figure, show
p = figure(plot_width=1000, plot_height=600,
title="TestTitle", x_axis_label = "Length [cm]", y_axis_label="Height [m]")
p.xaxis.axis_label_text_font_style = "normal"
p.xaxis.axis_label_text_font_size = "12pt"
show(p)
I am using Windows 7 and tried this in the current versions of Chrome and IE. Python 3.6, bokeh version 0.13.0. The first image is taken from the example, the second is taken from my real code:
I tried different figure sizes, but the problem persists - maybe I am trying the wrong ones? Anything I can do about this, except simply trying different sizes until something "works"? Setting px instead of pts seems to make it worse...
Regarding the text, it is rendered on to a raster HTML canvas, and the details of how this is done are entirely dependent on the browser canvas implementation. (FWIW things look better on any browser on OSX than the above image.) There's not anything we can to change how a specific browser renders text, and not much I can suggest except to make much bigger canvas sizes if you need to show something extremely magnified.
Regarding the aliasing of the axes and tick marks, I can't reproduce anything like that on any OSX browser (Safari, FF, or Chrome). It definitely appears to be a Windows-specific issue. It's possible there are issues that could be addressed, e.g a different HiDPI setting, or half-pixel offsets, but it would take investigation to try and determine what can be done. A Github issue with details would be appropriate, but I can't speculate when it might be addressed (we are under-resourced and no core contributors are regular windows users).
I'm writing a web interface for a database of genes values of some experiments with CGI in Python and I want to draw a graph for the data queried. I'm using matplotlib.pyplot, draw a graph, save it, and perform it on the web page. But usually there are many experiments queried hence there are a lot of values. Sometimes I want to know which experiment does one value belong to because it's a big value, whereas it's hard to identify because the picture is small in size. The names of the experiments are long strings so that it will mess the x axis if I put all the experiment names on the x axis.
So I wonder if there is a way to draw a graph that can interact with users, i.e. if I point my mouse to some part on the graph, there would be one small window appears and tells me the exact value and what is the experiment name here. And the most important is, I can use this function when I put the graph on the web page.
Thank you.
What you want is basically D3.js rendering of your plots. As far as I know, there are currently three great ways of achieving this, all under rapid development:
MPLD3 for creating graphs with Matplotlib and serving them as interactive web graphics (see examples in Jake's blog post).
Plotly where you can either generate the plots directly via Plotly or from Matplotlib figures (e.g. using matplotlylib) and have them served by Plotly.
Bokeh if you do not mind moving away from Matplotlib.
I'm writing an e-book reader in Python + wxPython, and I'd like to find out how many lines of text can be displayed in a given RichTextCtrl with the current formatting without scrolling.
I thought of using and dividing the control's height by RichTextCtrl.GetFont().GetPixelSize(), but it appears that the pixel size parameter of wx.Font is only specified on Windows and GTK. In addition, this won't cover any additional vertical spacing between lines/paragraphs.
I could of course get the font size in points, attempt to get the display's resolution in ppi, and do it that way, but 1) the line spacing problem still remains and 2) this is far too low a level of abstraction for something like this.
Is there a sane way of doing this?
EDIT: The objective is, to divide the ebook up into pages, so the scrolling unit is a whole page, as opposed to a line.
Source code of PageDown method suggest that there is not a sane way to do this...
Here is my insane proposition (which breaks widget content, caret, displayed position...) which scroll one page and measure how long this scroll is...
def GetLineHeight(rtc):
tallString = "\n".join([str(i) for i in xrange(200)])
rtc.SetValue(tallString)
rtc.SetInsertionPoint(0)
rtc.PageDown()
pos = rtc.GetInsertionPoint()
end = tallString.find("\n",pos)
lineHeight=int(tallString[pos:end])
return lineHeight
Did you try calling the GetNumberOfLines() method? According to Robin Dunn, that should work, although it doesn't take wrapped lines into account.