In matplotlib, how can I adjust the font size and weight of a tick label using a stylesheet? - matplotlib

I recently started experimenting with a stylesheet (.mplstyle) for my graphs. I found examples for altering the font globally,specifically for the labels and for titles:
axes.labelweight: bold
axes.titleweight: bold
font.size: 12
However, in the documentation I can't seem to find a way to adjust the ticklabel font, font-size and/or weight. Note that the syntax is different for stylesheets (.mplstyle) than doing it right in the code (for example, using rcParams doesn't seem to work).
I tried the following already but got a "Bad key" error:
Axes.set_yticklabels: fontdict:{'fontsize': 8,
'fontweight': rcParams['axes.titleweight'],
'verticalalignment': 'baseline',
'horizontalalignment': loc}

Very late answer here, but I found your post while trying to figure the same thing out. You've probably figured it out, but I thought I would comment so others that find this post find the answer.
You simply set:
xtick.labelsize : 10
ytick.labelsize : 10
If you want a fontsize of 10 for instance.

Related

Matplotlib Tex Set Font

I would like to have a matplotlib plot in my Latex document that uses the same font as the rest of the document. I read in the matplotlib documentation that if you set the rc parameter 'usetex' to true it will use the 'Computer Modern' font, which is also the standard for Latex.
Trying this gave me the following result.
The title of the plot is generated by matplotlib, the caption by the Latex document. As you can see, the font doesn't match. I think both use 'Computer Modern', but not the same font family. The title (by matplotlib) might be something like 'Sans Serif Roman', while the caption (by the Latex document) is something like 'Serif Roman'. I tried to change the font family with the following:
plt.title("Lorem Ipsum", family='serif', fontsize=20)
But it has no effect as long usetex is activated. I also tried it with fontdict, but it also did not change the font in any way. Also writing the name of a font directly to family does not work.
Is there any way to get the same font as in the Latex document?
Ok, after speding yesterday half a day with searching a solution, I now stumbled over it 5 minutes after asking the question.
Solution:
plt.rcParams['font.family'] = 'serif'
For some reason when usetex=True, setting the fontfamily works only globally.

Missing background style on Autodesk.Viewing.GuiViewer3D few examples

Missing background style on following Autodesk.Viewing.GuiViewer3D examples.
Would you update it, please?
https://forge.autodesk.com/en/docs/viewer/v2/reference/javascript/guiviewer3d/#registercontextmenucallback-id-callback
https://forge.autodesk.com/en/docs/viewer/v2/reference/javascript/guiviewer3d/#setcanvasclickbehavior-config
Images:
Autodesk.Viewing.GuiViewer3D registerContextMenuCallback
Autodesk.Viewing.GuiViewer3D setCanvasClickBehavior

How does one enter a 'checkbox' character on a pdf generated by report4pdf?

So I am working on generating PDFs using the report4PDF package(bob nemec) from the VisualWorks 8.1 software from Cincom. I am doing everything in 'smalltalk'.
However right now, the issue I am facing is that I can't get a checkbox
character to show up on the PDF.
So my code would go along like this:
pdfDocument := Report4PDF.R4PReport new.
exporter := SAGETEAPDFDataExporter onDocument: pdfDocument.
exporter currentText text string:' Available'.
"Followed by relevant code to save PDF"
But what shows up on my PDF is basically ' Available'. A space appears instead of the checkbox symbol. I even tried using dingbats codes(e.g: #9744 ). Works with the copyright, alpha, gamma symbols. Not with the checkbox symbol.
I tried updating my VisualWorks image from the public repository using the report4pdf, pdf development and fonts development packages. Ran into some
issues which I wont mention since it will derail us from the topic.
Thanks in Advance!
Okay... So I ended up finding a solution to this question. I will just
post the answer here just in case anyone else gets in a similar situation.
pdfDocument := Report4PDF.R4PReport new.
exporter := SAGETEAPDFDataExporter onDocument: pdfDocument.
exporter currentText text:[:text|
text string zapfDingbats ;string:'q'.
text string helvetica; string:'Available' ].
So you can use dingbats font to get a similar character for checkbox. You use
mixed fonts to get something like this:' (Checkbox) Available'.
So that's like the string is: 'q Available'. But 'q' is of the dingbats font while the 'Available' substring is of Helvetica.
Hope that helped. And thank you again #Leandro for trying to help me :)
Cheers!

Easeljs getBounds, when are dimensions set?

I'm importing someone's createjs application into an application loader which imports each developers application javascript to a global canvas. The application is working standalone but when I load the javascript dynamically I'm getting some strange behavior surrounding the getBounds() function.
I have some text created like this:
dialogText = new createjs.Text(text, 'bold ' + (28 * scale) + 'px Calibri', '#FFFFFF');
Then later on I use dialogText.getBounds() which returns null.
I try console logging dialogText and I can see that it is set and there is a value _bounds which reads null.
At what point do these values get set when the element in drawn to the canvas?
Note: I'm already adding the text to a createjs.Container() which has its bounds set before I run getBounds().
For a quick reference, I pasted EaselJS's update regarding getBounds():
(This dates back from "August 21, 2013", not sure if this is still necessary nowadays, but using setBounds(x, y, w, h) helped me with Shapes today [in 2017] actually!)
Source: http://blog.createjs.com/update-width-height-in-easeljs/
The _bounds property reflects a value that is manually set on the DisplayObject - which is helpful if you know the bounds of something that can't calculate it (like a Shape). It will always be null, unless you set it directly.
I tested your code, and it seems fine. Are you sure the scale or text values are not null? Maybe hard-code them to see if it works.
Do you have a sample somewhere? I noticed in the GitHub issue you posted that you mentioned it worked fine without RequireJS (though you don't mention that here). I would definitely ensure that the values are being set properly.
Here is the fiddle, as well as a simpler one with no EaselJS stage. Note that I have Calibri installed on my machine, so you might get different results if you are loading it in.
Sample code:
var dialogText = new createjs.Text("This is some text", 'bold ' + (28 * 1.5) + 'px Calibrix', '#FFFFFF');
console.log(">>",dialogText.getBounds());

Dojo spider chart with one series

Having trouble spider charting with only one series.
I tried working off this example:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_spidersingle.html
And set that up here:
http://jsfiddle.net/mstefanko/FHnwd/72/
Firebug is throwing:
Unexpected value NaN parsing cy attribute.
I'm completely new to the dojo toolkit. I know I need to addAxis, but it doesn't look like the code from the top URL is working. The axis is starting and ending at the same number despite my trying to set min/max.
Any help is appreciated!
Problem has to do with spider charts figuring out the min/max of the axis on it's own. Even when I was using:
chart1.addAxis("Answer 3", { type: "Base", min: 0, max: 250 });
to set the min and max, the spider chart still bombed with only one series.
After playing around with the information in this ticket:
http://bugs.dojotoolkit.org/ticket/14583
I still wasn't able to get this working, I stumbled onto an answer here that basically said as a workaround add series for min and max then remove them after render. So thats exactly what I ended up doing.
chart.render();
chart.removeSeries("min");
chart.removeSeries("max");
Demonstrated here:
http://jsfiddle.net/FHnwd/90/