I recently upgraded bokeh from 0.12.4 to 0.12.10, primarily to enable Plot.output.backend = "svg" for the SaveTool. This feature works pretty well, but I've been experiencing other plotting issues when it is enabled.
I have a layout based plot composed of 2 subplots and a slider panel, but the issue seems to be plot- and glyph-independent. For example, the first plot in the layout is based on:
p1=figure(width=1500, x_range=get_xrange(rawdat), tools="box_zoom,tap,xwheel_zoom,reset,save", y_range=get_yrange(rawdat))
source = ColumnDataSource(data=dict(ps=rawdat.ps, logsp=-log10(rawdat.p_score), radii=rawdat.radii, alpha=rawdat.alpha, color=rawdat.color, mafcolor=rawdat.mafcolor, weightcolor=rawdat.weightcolor, outcol=rawdat.outcolor, outalpha=rawdat.outalpha, alpha_prevsig=rawdat.alpha_prevsig, snpid=rawdat.rs, rs=rawdat.ensembl_rs, maf=rawdat.maf, csq=rawdat.ensembl_consequence))
p1.circle(x='ps', y='logsp', radius='radii', fill_alpha='alpha', fill_color='color', line_color='outcol', line_alpha='outalpha', line_width=6, radius_units='screen', source=source)
When Plot.output.backend = "svg" is enabled, glyphs overflow outside of the plotting region (especially when zooming), so much so that my circles collide with the bokeh toolbar, as below:
This behaviour happens no matter what the glyphs are (on plot 2, segments and rectangles do the same). When the backend is set to the default, the plot does not overflow. This happens on Opera, Vivaldi, Safari and Firefox.
I'd like to see if other people have experienced and/or solved this before I raise an issue on their github page.
Related
Heyo,
I've just stumbled upon this weird issue with my GLTF import: When loading the file in my three.js viewer, the colors looking different from the original file.
Compare McCudy's viewer:
GLTF file as seen in https://gltf-viewer.donmccurdy.com/
With my three.js viewer:
three.js viewer with ambient light brightness increased unhealthily
And again McCurdy's viewer but set to linear color encoding:
GLTF file as seen in https://gltf-viewer.donmccurdy.com/ with linear encoding
Looks familiar right?
I've already tried what three suggests: changing the color encoding of the renderer to sRGBEncoding but this problem is it doesn't change anything. Regardless of whether I use linear or sRGB encoding, the colors look the same. I checked the renderer and the outputEncoding is applied correctly.
Any idea's to why the setting does not seem to be applied or what else could be the source of the color change?
For information, I'm running a fairly old version of three.js (r97) which for various reasons I cannot update.
In three.js r112, the renderer.outputEncoding property was added, replacing the older renderer.gammaOutput property. In any earlier versions, the equivalent of renderer.outputEncoding = THREE.sRGBEncoding would be:
renderer.gammaOutput = true;
renderer.gammaFactor = 2.2;
If materials have already been rendered before these settings are configured on the renderer, you may also need to set material.needsUpdate = true to recompile them.
I am developing on an application based on VTK and GDCM for viewing medical (DICOM) images.
The application has three windows that respectively show XY, YZ and XZ orientations (axial, coronal and sagittal). This is similar to the 2D views here. I use vtkImageViewer2 for this. The voxel values of the DICOM images are passed on to an instance of vtkImageData. The instance of the vtkImageData is the passed on the to three instances of vtkImageViewer2 (let's use imageViewerXY, imageViewerYZ and imageViewerXZ). The orientation of each instance of vtkImageViewer2 is then set using SetSliceOrientationToXY(), SetSliceOrientationToYZ() and SetSliceOrientationToXZ(). Without the mask, I can see the slices, couple the windows and scroll through the images perfectly fine.
To add the mask so that it is shown in the three views, I use vtkImageActor. For the XY view, which is the default view, this works fine. I update the instance of vtkImageActor, which I call maskActorXY based on the mouse events of XY window as follows:
int extent[6];
imageViewerXY->GetImageActor->GetDisplayExtent(extent);
maskActorXY->SetDisplayExtent(extent);
maskActorXY->Update();
imageViewerXY->GetRenerer->Render();
Now, when I do the same for the other two windows so that I can see the 3D mask in the other two orientations, for example for the YZ orientation,
imageViewerYZ->GetImageActor->GetDisplayExtent(extent);
maskActorYZ->SetDisplayExtent(extent);
maskActorYZ->Update();
imageViewerYZ->GetRenerer->Render();
I get an error message that traces to vtkImageData and accessing pixel values outside of the extent set for the mask actor.
I have a limited familiarity with VTK, but looking at the source code of vtkImageViewer2 (see UpdateDisplayExtent() on line 341), I don't understand why pixel values out side of the specified display extent are requested from my instances of vtkImageActor that represent the mask.
I found a solution. Since I am not familiar with VTK, I may not be able to provide a clear explanation. All that I needed were the following two lines for each mask to force its mappers to face the camera:
maskActorYZ->GetMapper()->SetAtFocalPointOn();
maskActorYZ->GetMapper()->SliceFacesCameraOn();
(see [vtkImageMapper3D][1] class.)
I'm looking at the gorgeous and powerful Plotly Python API with the goal of generating a static html dashboard.
This raises two questions:
For generating html, I see the following example. It appears the charts are embedded via a URL. Does this URL embedding implementation still apply since plotly has gone open source? Are there now other methods for sending plotly plots to static html?
How does one control the layout of the plots/dashboard elements? In Bokeh, for example we could do something like:
bar = Bar(<define bar plot>)
line = Line(<define line plot>)
donut = Donut(<define donut chart>)
bar_line_panel = hplot(bar, line)
final_layout = vplot(bar_line_panel, donut)
output_file('foo.html')
show(final_layout)
The rendered html file would contain the line and bar plots next to each other above the donut chart. Is there similar functionality in plotly, or are templates and html/css wrangling required to specify layout for plot elements like in this example?
Thank you for your time, very much looking forward to creating some interactive visualizations in Plotly!
Is there a simple way to automatically fit a Bokeh plot to the screen used to display your browser? Right now I'm setting the plot width and height manually.
Note: when I say fit I mean that I want the plot to fill 80% of the visible screen.
In more recent bokeh versions, yes you can do this (easily).
plots and layouts now have a sizing_mode property which by default is set to fixed. The other values include scale_width, scale_height, and scale_both.
import bokeh.plotting
import bokeh.layouts
fig1 = bokeh.plotting.figure()
fig1.sizing_mode = 'scale_width'
fig2 = bokeh.plotting.figure()
fig2.sizing_mode = 'scale_width'
column = bokeh.layouts.column([fig1, fig2])
column.sizing_mode = 'scale_width'
As in the example above, your layout will need to have its sizing_mode attribute set appropriately to let its children plots expand.
Using the above example your plot will expand to the size of its container. It's up to you to appropriately size the container (using CSS) to suit your needs.
Note that the width/height property of your figures/plots still matter: they determine the ratio at which the bokeh layout scales.
I've been using gRaphaël charts for a few weeks now, and every now and then I get some weird issues. A recurring theme is that the pie chart legend labels all get squish together in the wrong places. Picture > words:
The chart is created as you would expect, in this case:
var r = Raphael(domNode, 300, 120);
this.chart = r.piechart(55, 55, 50, [75, 25],
{
colors: [
"000-#d00-#900",
"000-#3a3-#070"
],
legend: ["Building", "Tertiary Education"],
legendpos: "east"
});
I then do some more basic styling, but turning that off doesn't help. The problem is clearly visible in the <svg> node (the text and circle nodes share overlapping positions), but I don't know where it comes from or why, and it only happens sometimes; other charts work just fine. There's nothing on the forums or issue tracker either, though I just realised I should probably ask there instead/as well.
Using Raphaël 2.1.0 and g.Raphael 0.51.
I have found the following blog post which deals with this exact problem. If the pie chart is rendered in an initially hidden element, gRaphael has problems to compute the positions properly resulting in this stacked legend:
So the solution is to render the facebox partial first, after the
facebox is shown, then you execute the Raphael Javascript. In other
word, make sure you generate the chart when the chart container is
there and not hidden!
I have solved this by moving the create pie chart function from the jQuery document ready directive to the on click event that will make the hidden elements visible.
Try to define your legend as following
{ legend: ["Building", "Tertiary Education"] , legendpos: "east"}
Its the only difference taht I could find between your and my working jsfiddle