Ipython Bokeh Scatter Plot Marker Size after Zoom - zooming

When using bokeh scatter function with the code below:
import numpy as np
import bokeh.plotting as bpl
bpl.output_notebook()
x=np.linspace(-np.pi,np.pi,100)
y=np.sin(x)
bpl.scatter(x,y)
bpl.show()
I can use the wheel zoom and box zoom tools to zoom into the plot, and the markers keep a fixed display size. If instead I explicitly set the marker (glyph) size, like in the following code
import numpy as np
import bokeh.plotting as bpl
bpl.output_notebook()
x=np.linspace(-np.pi,np.pi,100)
y=np.sin(x)
bpl.scatter(x,y,radius=y/10)
bpl.show()
the marker size scales accordingly to the zoom scale. How can I set explicitly the marker size and keep at the same time a fixed display size independently of the zoom scale, as it is the standard behavior of mpl3d?

You need to give the plot a size instead of a radius. By default, size is in screen space units, and radius is in data space units.

Related

Scale SVG coordinate system without scaling element sizes

I have a bunch of circles in SVG.
I would like to zoom in 2x such that the distances between all the circles are 2x apart, but the stroke-thickness and radius remain the same.
(I use circles here as an easy example, but the same idea extends too all shapes. I would like the end points of lines to become 2x far apart but keep the line thickness the same.).
Thanks in advance.

Increasing the width of line drawn using Shape Renderer in LibGDX

I am drawing a line using Shape Renderer in LibGDX and i am using Orthographic Camera in my code, so to increase the width i used
camera = new OrthographicCamera();
int lineWidth = 8; // pixels
Gdx.gl10.glLineWidth(lineWidth / camera.zoom);
Now, I get a wider line. But the problem arises when the screen power goes off and then turns on, the line becomes the normal one again. How to keep the width constant?
ShapeRenderer has the method rectLine that is intended to be used to draw thick lines. It draws a rotated filled rectangle with the smaller opposite sides centered on the points passed to it (as coordinates or as Vector2 objects). The method has the parameter width to set the line width.
You can see the documentation here
Example:
shapeRenderer.rectLine(new Vector2(x1,y1),new Vector2(x2,y2),lineWidth);
As you can see here:
libgdx Shaperenderer line .. How to draw line with a specific width
And here:
Libgdx gl10.glLineWidth()
And here:
Why Libgdx Gdx.gl10.glLineWidth(width); does not react to change projection properities
Playing with the line width in the shaperenderer isn't the best way to do what you want to achieve.
Try using a 1x1 white TextureRegion (you can change the color the Batch draws it with later), and draw it with the width and height that you desire:
batch.draw(region, x, y, width, height);

Away3D: How to resize an ObjectContainer3D instance

my question is: how can I resize an ObjectContainer3D instance (as it doesn't have "width", "height" and "depth" properties)?
Maybe you can use 'scaleX', 'scaleY', 'scaleZ', or 'scale'.
Note that this will chance the size of the objects in the ObjectContainer3D within the 3D space. Not sure if that's what you're trying to do, given that 3D objects have width, height & depth.
In 3D space there is no concept of pixels. Usually the size is in "units". What you are looking for is a way to render pixel perfect textures. So a pixel mapped onto the 3D object renders as a pixel on screen. This is usually achieved by moving the object at a specific distance from the camera.
Here's a link to a blog post I found on the subject that should point you in the right direction.
In the end the size of the actual 3D object doesn't matter. What matter is the scale and mainly the aspect ratio to render texture as needed. To render a 400px by 200px texture on screen, the 3D plane can be 4 units by 2 units. After that positioning it correctly in front of the camera will produce a 400px by 200px image on screen.
hth.
J.

How can I have a jfreechart ChartPanel automatically enlarge itself?

I have a Swing JFrame with a ChartPanel as its only component. When I resize the frame, the chart panel gets stretched out as if it were an image. For example, if I shrink it vertically, all of the character get compressed.
Is it possible to have the ChartPanel redraw itself on resize events so that it shows more detail on the graph, instead of getting stretched as a static image?
You have to change a few options when constructing your ChartPanel :
* #param minimumDrawWidth the minimum drawing width.
* #param minimumDrawHeight the minimum drawing height.
* #param maximumDrawWidth the maximum drawing width.
* #param maximumDrawHeight the maximum drawing height.
I had the same issue. I now realize that ADR gave the solution: you have to set the minimum and maximum drawing width and height, for example:
chartPanel.setMinimumDrawWidth( 0 );
chartPanel.setMinimumDrawHeight( 0 );
chartPanel.setMaximumDrawWidth( 1920 );
chartPanel.setMaximumDrawHeight( 1200 );
ChartPanel has methods to control zoom, as shown in this example. I don't see characters getting compressed.

how to get scaled height and width?

I have a s:Group with few fixed size components in it, these are lets suppose 200x300, 300x150 etc
Now if i resize s:Group with resizeMode=Scale, (scale down). and try to read the scaled down size of these child components but they still has the same old height and width.
how can i get width and height after scaling down the parent group?
Thanks
Try myComponent.transform.pixelBounds.width. That should give you an actual measured width wrt the visible X-Axis. If you are rotating, but you want the scale along X-Axis wrt the component, see this post on obtaining the scaling of an object.
Hey there :]
At first i thought it would be an easy task to get the width and height. But when i tried it, none of explicitWidth and measuredWidth worked, when resizeMode is set to "scale" of the s:Group.
So i found a way but i'm not sure if it's the best solution:
write this in your script tag:
import mx.core.mx_internal;
use namespace mx_internal;
then if you have
Group id="group" resizeMode="scale"
and a s:Button id="myButton" inside it
in order to get the myButton width for example, just compute group.$scaleX * myButton.width
Hope this will work.
all the best,
blz