Bold x axis values in jfreechart - jfreechart

How can I bold the x and y axis values in jfreechart?

Have you tried one of those:
yourAxis.setTickLabelFont(new Font("Arial", Font.BOLD, 10)); //to define a specific font
or
Font bold = yourAxis.getTickLabelFont().deriveFont(Font.BOLD);
yourAxis.setTickLabelFont(bold); //to use the existing font, but bold

Related

Formatting Sum of negative value

I am creating a report in SSRS. I want to sum a column and change the color to red if value goes to negative. But my expression is not working. Here is my expression.
=IIF(SUM(Fields!Column.Value) < 0, "Red", "Black")
You need to put the expression in the font color and not the cell value.
To do this : right click on the cell you want the font color to change - text box properties - Font - click on the Fx next to the color and then place the expression
=IIF(SUM(Fields!Column.Value) < 0, "Red", "Black")
This will change the font color based on it's value

How to change colour of specific points in ggtern

I am using ggtern to graph some RGB data, where each point refers to the colour % from red, green or blue.
I was wondering if it is possible to change the colour of specific plot points to match the actual colour which they are representing?
I have tried using some ggplot2 commands but it doesn't work.
This is what I am using now:
library(ggplot2)
library(ggtern)
library(readxl)
Image9 <- read_excel("~/PhD/Image9.xlsx")
View(Image9)
ggtern(data=Image9, aes(x = Blue, y = Red, z= Green )) + geom_point( size=2,
shape=16, color="black") + theme_rgbw() + theme_hidegrid_major() +
theme_hidetitles()+ theme_rotate(degrees = 120) +
geom_text(aes(label=Colour), size=3, color="black", hjust=0, vjust=0)
Using this command I can plot the data as a colour intensity percentage in Red, Green and Blue and label the points so that I can map them back to the original image
1; representative image of plot.
Ideally I would like to plot each point as the same shade of color which they represent within the color space, I don't know if this is possible with this package.
Any suggestions would be greatly appreciated.

How to interpolate a HSV color?

I am creating an application in win32 api, which will use a progress bar. This progress bar, should change its color. From red (left end) to green(right), and in the middle some yellow.
I searched a little, and found out, that I should use HSV to achieve this. I just don't know how? I found in this link, two functions, to convert the color, from RGB to HSV and back.
But what should I do if the color has been converted to HSV?
Like RGB coordinates, HSV coordinates define a point in a three dimensional space.
You may find a trajectory form one point (x0, one color) to the second (x1) with a formula like:
x = x0 + alpha * (x1-x0)
with alpha varying form 0.0 to 1.0
You can do this for all three components simultaneaously.
With a trajectory from green to red in HSV space you will mainly modify the H (Hue) value. If you want to see some yellow in the middle of your path (and not violett) you need to define a second or even third color and walk
green -> yellow -> red
Edit: Example
int hue0 = 0; // red
int hue2 = 120; // green
// find 100 colors between red and green
for(double alpha = 0; alpha <= 1.0; alpha += 0.01)
{
hueX = hue0 + alpha * (hue1 - hue0);
// same for value, saturation:
// valX = val0 + alpha * (val1 - val0)
// ...
// plot this color
}

JfreeChart Axis custom precision or range

I am trying to plot a XYPlot using JfreeChart. My X axis has number or client say 30, 50 ,70
and Y axis has cache hit ratio( Value of which sometime varies by 0.01) When i set AutoRange the y axis show range as 0.1 0.2 0.3..... 1.0. So sometimes my plot is nearly straight line since it varies by such a small factor.
I have tried this code
JFreeChart chart = ChartFactory.createXYLineChart(
"Effect of Number of Clients", // Title
"Number of Clients", // x-axis Label
"Cache Hit Ratio", // y-axis Label
datasetLRU, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
chart.setBackgroundPaint(Color.white);
plot= chart.getXYPlot();
plot.setBackgroundPaint(Color.black);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
final ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(false);
final NumberAxis axis2 = new NumberAxis("Axis 2");
axis2.setAutoRangeIncludesZero(false);
axis2.setTickUnit(new NumberTickUnit(0.01));
plot.setDataset(1, datasetMARS);
plot.setRenderer(1, new StandardXYItemRenderer());
plot.setDataset(2, datasetNEW);
plot.setRenderer(2, new StandardXYItemRenderer());
So Can any one help in setting Y axis range as 0.01 0.02 0.03 .... 0.98 0.99 1.00
Thanks
Your code doesn't configure the range axis because you create axis2 but you never assign it. When using auto range you can also configure the minium size of an auto ranged axis (method setAutoRangeMinimumSize(double)).
Please try the following source code part:
final NumberAxis axis2 = plot.getRangeAxis();
axis2.setAutoRange(true);
axis2.setAutoRangeIncludesZero(false);
axis2.setAutoRangeMinimumSize(0.001);
axis2.setTickUnit(new NumberTickUnit(0.01));

winforms chart, change values on x axis

I have added values on x axis between 0-255. I add the values to a serie with serie.addXY(127,10000); When the chart is displayed, the values it shows on the x axis are -1, 49, 99...
How can I change this to display 0, 50,100?
Try setting axis bounds. You can do that in the designer or via code:
Chart1.ChartAreas["Default"].AxisX.Minimum = 0;
Chart1.ChartAreas["Default"].AxisX.Maximum = 255;

Resources