graphics

ggplot2: piecharts instead of points in an xy scatterplot

寵の児 提交于 2019-12-19 10:22:31
问题 I have a four-dimensional dataset, let's call the variables x, y, z and r. There is at most one entry for each combination of x and y. Currently, I have a scatterplot where I plot for each entry a point at position (x,y) and size z. ggplot(aes(x=x,y=y)) + geom_point(aes(size=z)) This produces a nice plot, but now I would like to "upgrade" it as follows: I want to replace each point with a piechart, and the piechart should be the same size as the point. The pie consists of two sections, one

Drawing slices of a circle in java?

被刻印的时光 ゝ 提交于 2019-12-19 09:53:25
问题 I want to represent a timer by having a filled circle which is fully drawn over the course of the timer by segment. I.e. If the circle is filled in every 1 second for a timer of 4 seconds the first will show a quarter of a circle then a half then three-quarters and finally a full circle. Is there a way to draw these slices of a circle in java? I've looked into arbitrary shapes in the graphics API but not sure if this is the right way to go or if there is something written into the language

Drawing slices of a circle in java?

我怕爱的太早我们不能终老 提交于 2019-12-19 09:53:05
问题 I want to represent a timer by having a filled circle which is fully drawn over the course of the timer by segment. I.e. If the circle is filled in every 1 second for a timer of 4 seconds the first will show a quarter of a circle then a half then three-quarters and finally a full circle. Is there a way to draw these slices of a circle in java? I've looked into arbitrary shapes in the graphics API but not sure if this is the right way to go or if there is something written into the language

Undestanding UIBezierPath curving mechanism, controlPoint and the curve point

烈酒焚心 提交于 2019-12-19 09:24:40
问题 I'm trying to draw a simple Parabola shape using UIBezierPath . I have a maxPoint and a boundingRect of which I'm basing the width and stretch of the parabola. Here's the function I made to draw the parabola (I draw the parabola in a container view, rect will be container.bounds ): func addParabolaWithMax(maxPoint: CGPoint, inRect boundingRect: CGRect) { let path = UIBezierPath() let p1 = CGPointMake(1, CGRectGetMaxY(boundingRect)-1) let p3 = CGPointMake(CGRectGetMaxX(boundingRect)-1,

Draw border around bitmap

帅比萌擦擦* 提交于 2019-12-19 08:44:27
问题 I have got a System.Drawing.Bitmap in my code. The width is fix, the height varies. What I want to do, is to add a white border around the bitmap, with about 20 pixel, to all 4 edges. How would this work? 回答1: You could draw a rectangle behind the bitmap. The width of the rectangle would be (Bitmap.Width + BorderWidth * 2), and the position would be (Bitmap.Position - new Point(BorderWidth, BorderWidth)). Or at least that's the way I'd go about it. EDIT: Here is some actual source code

Draw border around bitmap

拜拜、爱过 提交于 2019-12-19 08:44:10
问题 I have got a System.Drawing.Bitmap in my code. The width is fix, the height varies. What I want to do, is to add a white border around the bitmap, with about 20 pixel, to all 4 edges. How would this work? 回答1: You could draw a rectangle behind the bitmap. The width of the rectangle would be (Bitmap.Width + BorderWidth * 2), and the position would be (Bitmap.Position - new Point(BorderWidth, BorderWidth)). Or at least that's the way I'd go about it. EDIT: Here is some actual source code

Why the leading “#FF” in hexadecimal color values?

与世无争的帅哥 提交于 2019-12-19 07:41:33
问题 I'm using Expression Blend 3 and writing some of the XAML by hand, specifically the color values of controls. I have a list of RGB colors already converted to hexadecimal. I just need to insert the hex value into my XAML. Initially, I pasted the hex value from an email into the appropriate properties. Before I could finish, Blend started having a fit, underlining the color property with a squiggle and a tooltip telling me "Token is not valid." After some research, I found placing a pound sign

JPanel custom drawing using Graphics

*爱你&永不变心* 提交于 2019-12-19 07:32:31
问题 I have a custom JPanel and sometimes throughout my program, I need to call a method which paints the screen black, that's it. public void clearScreen() { Graphics g = getGraphics(); g.setColor(Color.black); g.fillRect(0,0,getWidth(),getHeight()); } When I launch the program, I call this method. However, I find that sometimes it works, and sometimes it doesn't. It's very odd. I also found out that when it doesn't work, the graphics object is NOT null, and the width and height are also

ggplot specific thick line

吃可爱长大的小学妹 提交于 2019-12-19 07:22:05
问题 How would one be able to plot one line thicker than the other. I tried using the geom_line(size=X) but then this increases the thickness of both lines. Let say I would like to increase the thickness of the first column, how would one be able to approach this? a <- (cbind(rnorm(100),rnorm(100))) #nav[,1:10] sa <- stack(as.data.frame(a)) sa$x <- rep(seq_len(nrow(a)), ncol(a)) require("ggplot2") p<-qplot(x, values, data = sa, group = ind, colour = ind, geom = "line") p + theme(legend.position =

Set BufferedImage to be a color in Java

拈花ヽ惹草 提交于 2019-12-19 05:04:49
问题 I need to create a rectangular BufferedImage with a specified background color, draw some pattern on the background and save it to file. I don't know how to create the background. I am using a nested loop: BufferedImage b_img = ... for every row for every column setRGB(r,g,b); But it's very slow when the image is large. How to set the color in a more efficient way? 回答1: Get the graphics object for the image, set the current paint to the desired colour, then call fillRect(0,0,width,height) .