I'm creating a chart with jFreeChart :
final JFreeChart chart = ChartFactory.createLineChart(
"Line Chart Demo 1", // chart title
"Caf\00E9", // domain axis label
"Voil\00E0", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
As you can see, I have unicode characters for the labels in the axis :
"Caf\00E9" to display "Café" and "Voil\00E0" for "Voilà".
It works well when the app that generates this chart runs on "some" servers. For the others, it displays question marks ("?") instead of accentued chars.
As it doens't run all the time, I had the idea to force the encoding.
The question is : How can I force the labels to convert those unicode characters into readable ones ?
I cannot find in the documentation a way to can convert those strings properly.
I found some pieces of code on the net like this
domainAxis.setTickLabelFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
which I find interesting but, how could I apply it to the domain axis and range axis labels ?
Regards.
EDIT1:
I figured out how to "force" using a font :
Font font = new Font("Tahoma", Font.PLAIN, 12);
categoryplot.getDomainAxis().setLabelFont(font);
But, the output is still odd : for "Caf\00E9", it shows "Café". Is there a way to transform this string into a readable one (Café) ?
(I'd rather like to comment, but this reputation limit still blocks me ...)
It might be just a copy&paste typo, but please check that your unicodes are starting with "\u".
Furthermore on "some" (*nix) servers you might want to load the font from your own resources.
Related
So, I'm doing some odd things with text extrusion and (perhaps not surprisingly) having some odd issues in OpenSCAD.
This is part of a much larger project, but I've been able to simplify the problem down to the following snippet of code.
use<RingbearerMedium-51mgZ.ttf>
Text = "b";
Font = "Ringbearer:style=Medium";
segment_count = 2;
segment_width = 2;
text_height = 5;
text_thickness = 1;
// Iterate over each "segment" of text
for (segment_number = [0: segment_count - 1])
{
// Calculate the x offset of the current "segment" of text
segment_x_offset = segment_number * segment_width;
// Extrude the "segment" of text to the requested thickness
linear_extrude(text_thickness)
// Grab the current "segment" of text
intersection()
{
text(Text, font=Font, size=text_height);
translate([segment_x_offset, 0])
square([segment_width, text_height]);
}
}
All this does is generate a line of text (just "b", in this case), cuts it into "segments", then extrudes each segment in-place. It's not much use in this example, but in the larger one, I'm translating and rotating each segment.
OpenSCAD's F5 preview renders fine. Here's a screenshot:
F5 Preview
However, the F6 preview always drops the left side of the letter "b" and displays the error "ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron". Here's a screenshot:
F6 Preview
This effects other letters as well, but only seems to be a problem with the "Ringbearer" font I'm trying to use. I don't know if I can upload the font, but it's available for download for free from here: Link to Ringbearer Font. Extruding and rendering the font without breaking it into segments works just fine. It's just when I try to segment this particular font that OpenSCAD fails.
Now, the obvious answer is to use a font that works, which is fine, as far as it goes, but I'm genuinely curious why this is happening. Is it an error with the font or is this a limitation of OpenSCAD? Is this a known issue that I'm just not aware of?
I appreciate any insight I can get.
Within OpenScad, go to help->font list.
I think the font you are using isn't supported.
Yet I had a similar problem with a supported font. I changed the font few times until I found one that works for me well, and look nice as well.
It also depends on the font size. Sometimes same font fails at a smaller size, and works well on a larger size.
Anyway, you can see this on the slicer, before going to the printing. Take a close look at the slicing layers of the text, it will save you some printing time and frustration.
I am playing with the visual effect of plots, and a question came up while changing the style of a legend.
To be able to save the figure with legends big enough that can be seen usually one needs to change the FontSize property to e.g. 24. When you do that, the size of the font changes, however, the small line next to it has the same size than when it was small. The proportion between line/text seem quite appropriate to me with a FontSize of around 10, while I believe that with big font sizes bigger "eat" visually the line, which is the important part.
Example with fontsize 30 and 10 (please ignore how much I suck in mspaint and the low resolution of the zoomed legend). The proportion between line/text is nicer in the small one.
I was wondering if there is a way to modify that line. I have been checking the properties but I haven't found any relevant one.
NOTE: The LineWidth property does not change the width of the colour lines, but the width of the bounding box.
You could play with the outputs arguments of legend, especially the icons variable (check here).
According to the docs, they correspond to
Objects used to create the legend icons and descriptions, returned as
text, patch, and line object.
Therefore you might use something like this to modify the LineWidth property of any of your plot, or both of course:
clear
clc
close all
x = 1:10;
plot(x,rand(1,10));
hold on;
plot(x,x,'k');
[h,icons,plots,str] = legend('First plot','Second plot','Location','NorthWest');
set(h,'FontSize',30);
set(icons(:),'LineWidth',2); %// Or whatever
Which outputs:
Note that I used R2014a so it might be a bit different for R2014b.
I'm using MS Chart to render charts to a PNG file.
There are two Chart Titles that collectively are taking an inordinate amount of space on the page because
There is significant whitespace ("padding") around each title
There is significant whitespace between the two titles
Reviewing the WinForms sample project at
http://archive.msdn.microsoft.com/mschart
I see that many aspects of the title (font, color, border, ...) can be changed but I do not see an option to control padding around an individual title, or extra whitespace between two titles.
Am I missing something?
Are you sure it is the title eating all the space? You could check that by setting a title border to see exactly where its bounds are. Regardless, try setting the InnerPlotPosition for the corresponding ChartArea manually and see if you can solve the problem that way.
// Set the plotting area position. Coordinates of a plotting
// area are relative to a chart area position.
chart1.ChartAreas["Default"].InnerPlotPosition.Auto = false;
chart1.ChartAreas["Default"].InnerPlotPosition.X = 10;
chart1.ChartAreas["Default"].InnerPlotPosition.Y = 10;
chart1.ChartAreas["Default"].InnerPlotPosition.Width = 80;
chart1.ChartAreas["Default"].InnerPlotPosition.Height= 80;
The only way I could get adequate control over title rendering was to render it myself using a PostPaintHandler.
Chart c = new Chart();
c.PostPaint += (sender, e) => { /* Use e.ChartGraphics.Graphics for title */ };
I want to display overlapping boxplots using Sigmaplot 12. When I choose the scale for the x-axis as linear then the boxes do indeed overlap but are much too thin. See figure below. Of course they should be much wider.
When I choose the scale of the x-axis to be "category", then the boxes have the right width, but are arranged along each single x-value.
I want the position as in figure 1 and the width as in figure 2. I tried to resize the box in figure 1 but when I choose 100% in "bar width" than it still looks like Figure 1.
many thanks!
okay, I found the answer myself. In Sigmaplot, there is often the need to prepare "style"-columns, for example if you want to color your barcharts, you need a column that holds the specific color names.
For my boxplot example I needed a column that has the values for "width". These had to be quite large (2000) in order to have an effect. Why ? I have no idea. First I thought it would be because of the latitude values and that the program interprets the point as "1.000"s, but when I changed to values without decimals, it didn´t get better.
Well, here is the result in color.
Have fun !
I am creating a Chart (DataVisualization.Charting.Chart) programmatically, which is a Stacked Bar chart.
I am also adding Legend entries programmatically to it. I want to show the Legend at the bottom of the chart.
But, while doing so, the Legend overlapps with the X-axis of the chart.
Here is the code I am using:
Private Function GetLegend(ByVal legendName As String, ByVal s As Single) As System.Windows.Forms.DataVisualization.Charting.Legend
Dim objLegend As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend()
objLegend.Name = legendName
objLegend.Font = New System.Drawing.Font("Verdana", s)
objLegend.IsDockedInsideChartArea = False
objLegend.Docking = Docking.Bottom
Return objLegend
End Function
Below statement adds that Legend to the chart
_msChart.Legends.Add(GetLegend("SomeValue1", 10.0F))
Any idea, what is missing? I want to show the legend at the bottom only, but it should not overlapp with the X-axis.
I had the same problem today. Try adding:
objLegend.Position.Auto = true
objLegend.DockedToChartArea = "yourChartAreaName"
That did not help me but I found on the net that this might be helpful (and clean solution).
What actually worked for me was moving chart area to make space for legend so it no longer overlaps. My legend was on top so this code worked for me:
chart.ChartAreas[0].Position.Y = 15
You can try resizing it instead, forcing it to be for example 20 pixels shorter than chart.Size.
Hope this helps.
I had an overlapping legend/chart area problem as well but none of the other suggestions here seemed to make any difference. I think the problem stems from legend text wrapping to two lines and the sizing algorithms not taking account of this.
The ideas here got me thinking more clearly about the problem though, and I was able control the size and position of the chart area using the following.
Chart1.ChartAreas[0].InnerPlotPosition = new ElementPosition(15, 5, 90, 75);
There's not much intellisense on those parameters, but as well as I could deduce, the parameters are all percentages of the total chart area (I initially thought they might be pixel values and got some very odd results). So what I've written above would set the plot area to start at 15% in from the left edge of the chart image and 5% down from the top, and have a width of 90% and a height of 75%.