I'm plotting two lines, one solid, one dashed. At the initial zoom the lines appear as defined. However, when zooming into the plot the dashed line becomes solid. The pictures below illustrate the problem. Here is the code that defines the lines:
turbidity_stn3_plot1 = f.line(x='Datetime',y='Turbidity', y_range_name='default', color='olive',line_color='black', line_dash=[1,10], line_width=1, source=turbidity_stn_03_plot_01_source)
turbidity_stn1_plot1 = f.line(x='Datetime',y='Turbidity', y_range_name='default', color='olive',line_color='black', line_dash='solid', source=turbidity_stn_01_plot_01_source)
I already tried different 'line_dash' values, like 'dashed' and 'dotted' with the same result.
I noticed that, when increasing the distance between dashes (e.g. 'line_dash=[1,20]'), the closer I can zoom in before the line turns solid.
Does anybody know why this is and how to avoid it?
Should I report this as a bug on Bokeh Github?
This is a result of browser-dependent behavior of HTML canvas implementations. There is nothing that the Bokeh project can do about it (which is why the GH issue was eventually closed). If you are working in regimes where this issue shows up, the only alternative is to use other visual properties, e.g. width or color, instead of dashing.
Related
Is it just me or are some gridlines thicker than others?
If you look at the top plot, the vertical lines at 3.5 and 4 seem thicker than the other vertical lines. And the lines at 12.5 and 13.5 seem thicker than the other horizontal lines. In the plot below, you see the same for vertical 10 and horizontal 20 and 25. You can see this inconsistency in any other plot.
Is this just an optical illusion? If not, how can I make them consistent?
Edit: Taking a screenshot of the graphs changes the perceived thick lines, some previously thick lines become normal and some new lines get thicker. This leads me to believe this is just an optical illusion. Baffling nonetheless.
Edit 2: Here's an indepth look. This is from plotly's documentation page itself. You can see in the image the line in the lower plot is two pixels long. (The pixel reading is that of the line to the immediate left of it)
Edit 3: Here's more screenshots of my chrome browser and from my android phone. These too show inconsistencies in thickness.
Android-
Edit 4: Resizing the window changes the thickness of the lines, makes some thicker whilst making others thinner.
Also, checked plotly docs on a mac. Lines were consistent with same thickness.
This is definitely something in your local environment.
I open the plotly page you linked above (in Chrome), take a screenshot and paste into mspaint (so direct bitmap paste - no compression) and can see that all gridlines are 1px wide, except for the
axes, which are 2px.
I'm almost 100% certain that what you're seeing here is an aliasing effect caused by the image compression. As a test - try exporting the charts as BMP, or even a higher resolution jpg/png, and I'm fairly confident you won't see this.
I've started playing with pyqtgraph plotting line charts.
I have the need to draw specific dots in some section of the lines.
I found that in order for dots to appear on the line,
I need to use symbolBrush when plotting E.g
curve3 = p1.plot(pen=(2,5) , name="trade" , symbolBrush=2)
But the thing is it shows dots on the entire line,
and I can't seem to find a way to draw a dot for specific points / sections.
Assistance would be appreciated
Edit:
For example, In the attached image, assume I only want to draw a dot where marked (1,1) without dots being drawn on the other line breaks.
So, here is an example of what you are looking for. It's a bit "dodgy" in that I'm accessing something inside a PlotDataItem that probably shouldn't be directly accessed, so there is a risk that this code may become non-functional with future updates to pyqtgraph.
That said, I think the risk is reasonably low, it would be easy to update my example to work with whatever changes are made to pyqtgraph, and the example may spark an idea in you that leads to a path that achieves the same thing, without needing to abuse the internals of pyqtgraph.
pw = pg.PlotWidget()
x = np.arange(8)
y = [1,6,2,4,3,5,6,8]
p = pw.plot(x=x, y=y, symbolSize=25)
p.scatter.setData(x=[x[2]],y=[y[2]])
pw.show()
I'm making a relatively simple plot that seemed to work fine. I have a number of line segments, and each defines an area. I'm using polygons for the filled areas using plot.Polygon and ax.add_patch.
When I save to .png, everything works fine. So, I turn to pdf for the final image. I manually set things like fontsize, figsize and dpi, so there should be no problem.
Sadly, 2 out of the four Polygons in the current picture are not displayed in the pdf. Which is strange; the previous two images (other datasets) did act correctly. I've played around a bit with zorder and alpha on the Polygons but to no avail.
My google search did not turn up anything; it mentioned the dpi being different if you haven't set it manually, but this is no problem. Beyond that, I could find no clear reasons.
My sincere thanks,
Daimonie
Okay, so I've found the problem.
Let's first denote the method I use to add the polygons, just for clarity. The points $(x,y)$ that define the vertices are called vertices. The polygon is made as:
first_polygon = plt.Polygon(vertices, zorder=.1, facecolor=colours[colour_index], alpha=fill_opacity)
Next, I add it to the figure:
ax.add_patch(first_polygon)
So why didn't it display some polygons? I cannot be sure of the reason, but the issue resolved when I redefined the polygons. The two polygons that didn't display were bound by three lines. The first polygon was bound by y0, y1, y2 and the 'frame' of the figure. Because I was still scaling the figure, I had put the point that bound it by the 'frame' as $(100, -100)$. When I changed that to $(min_x, min_y)$ it suddenly displayed properly.
Is there any way at the moment to add constant tooltips to a bokeh line plot in python? I did not find anything about it in the documention.
I am looking for a way to allow adding the tooltip interactively ala matlab. However, doing so via the code at first is acceptable.
thanks.
Currently (as of 0.8.1) the line glyph does not support hit testing, so it does not support a hover tool, either. However, if it suffices to have a hover tooltip on just the "points" of the line, then several people have uses a second set of transparent markers located at the same points as a workaround. Something like:
line(x, y)
circle(x, y, size=8, alpha=0)
There is an open issue for adding line hit testing, it should hopefully been in one of the next few releases.
I am trying to minimize margins around a 1X2 figure, a figure which are two stacked subplots. I searched a lot and came up with commands like:
self.figure.subplots_adjust(left=0.01, bottom=0.01, top=0.99, right=0.99)
Which leaves a large gap on top and between the subplots. Playing with these parameters, much less understanding them was tough (things like ValueError: bottom cannot be >= top)
My questions :
What is the command to completely minimize the margins?
What do these numbers mean, and what coordinate system does this follow (the non-standard percent thing and origin point of this coordinate system)? What are the special rules on top of this coordinate system?
Where is the exact point this command needs to be called? From experiment, I figured out it works after you create subplots. What if you need to call it repeatedly after you resize a window and need to resize the figure to fit inside?
What are the other methods of adjusting layouts, especially for a single subplot?
They're in figure coordinates: http://matplotlib.sourceforge.net/users/transforms_tutorial.html
To remove gaps between subplots, use the wspace and hspace keywords to subplots_adjust.
If you want to have things adjusted automatically, have a look at tight_layout
Gridspec: http://matplotlib.sourceforge.net/users/gridspec.html