Set defalult plot linewidth in .octaverc - plot

I am starting out with Octave. I am using Octave 4.2.0 (compiled from source) on Debian.
I have found that using the qt or fltk graphics_toolkit, have default linewidth of 0.5. I want to change the default linewidth in my .octaverc file.
I have tried adding the following to my .octaverc (separately) but they both cause errors
linewidth:def.1.5000
set(gca (), "defaultlinewidth", "1.5")
How can I change the default line width of plots via the octaverc file?

It sounds like you want to set it on the root so that all plots will use it:
set(0, "defaultlinelinewidth", 1.5);
Here is the link to the relevant part of the manual.
15.3.5 Managing Default Properties
Object properties have two classes of default values, factory defaults
(the initial values) and user-defined defaults, which may override the
factory defaults.
Although default values may be set for any object, they are set in
parent objects and apply to child objects, of the specified object
type. For example, setting the default color property of line objects
to "green", for the root object, will result in all line objects
inheriting the color "green" as the default value.
set (0, "defaultlinecolor", "green");
sets the default line color for all objects. The rule for constructing
the property name to set a default value is
default + object-type + property-name
This rule can lead to some strange looking names, for example
defaultlinelinewidth" specifies the default linewidth property for
line objects.
EDIT:
Just to place emphasis on this: You've tried to set "defaultlinewidth" which is not a valid property as explained above. The property you want to set is "defaultlinelinewidth"

Related

How to set the default attributes of Plots?

In Julia plotting with Plots, I know how to set the various attributes when using plot() (Attributes).
I want to know how to set the default attributes, so that I don't need to set them every time.
For instance, I want to change the font-family to another one, or show the minor ticks always.
I googled but I can not find the way.
This is the way:
Use the default() function like so
using Plots
default(titlefont = (20, "times"), legendfontsize = 18, guidefont = (18, :darkgreen), tickfont = (12, :orange), guide = "x", framestyle = :zerolines, yminorgrid = true)
plot([sin, cos], -2π, 2π, label = ["sin(θ)" "cos(θ)"], title = "Trigonometric Functions", xlabel = "θ", linewidth = 2, legend = :outertopleft)
Taken from the documentation here. I know the Plots.jl docs can be a bit tricky to navigate due to their size, but in this case I just typed default into the doc search box.
Note that when using the default function you don't supply the keyword args in subsequent calls to plot, unless of course you want to change away from your newly specified defaults.
Since you are asking for a way to save defaults across sessions, I will also point you to this additional tip from the installation docs:
You can override standard default values in your ~/.julia/config/startup.jl file: PLOTS_DEFAULTS = Dict(:markersize => 10, :legend => false, warn_on_unsupported = false)
So here you are defining the new defaults as a dictionary which is used as an environment variable, which allows setting defaults before loading Plots (and thus without having the default function available).
Store your defaults in a variable and overwrite whenever needed.
defs = (linestyle=:dash, linewidth=5, linecolor=:green)
plot(rand(5);defs...,linecolor=:red)
My solution is to create an empty plot with all "default" attributes and then just add necessary layers each time to this empty plot.

Bokeh MultiLine p.add_tools(HoverTool(), renderers = [multiline]) not working

So when trying to add a HoverTool to a plot, the MultiLine Hover works.
But the problem I am having is, that I have another highlighting Single Line, that I do not want the Hover to act on.
So I wanted to input just the multiline to the renderers keyword
p.add_tools(HoverTool(tooltips = [('Name: ', '#Name'),
('Value', '#Value')],
renderers = [multiline]
)
and I am getting the following error:
ValueError: expected an element of either Auto or List(Instance(Renderer)), got [MultiLine(id='4982e76f-7dda-4d78-b729-240c9a29bdef', ...)]
What am I missing?
Glyphs (such as MultiLine) are more like a description of what to draw. There is a seperate GlyphRenderer that takes glyphs and uses them to draw (it can actually have several versions of a glyph to use in different cases, e.g. for selecting and highlighting and decimating). The renderers arg of the hover tool expects the GlyphRenderer, not the glyph.
If you are using bokeh.plotting, then the glyph renderer is returned by the method on the figure:
r = plot.multi_line(...) # r is what to configure on the hover tool
If you are using the low level bokeh.models API then you must already be configuring a GlyphRenderer manually for your MultiLine. Pass that to the hover tool instead.

How to define custom attributes for nginx cookbook?

For my current problem I'm using the nginxcookbook. What I want to do is to install it from source (no problem to do that using nginx::source) and prefix it to /opt/nginx/<version>/, but it will always be prefixed (by default) to /opt/nginx-<version>/.
This is my ./attributes/default.rb:
node.override['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
#also tested
override['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
#and also
default['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
What am I not understanding?
Thanks
An additional thing would be:
- How may I prefix it like above and create a sym-link to /opt/nginx/current (and do that even after update)?
So, this is a shortcoming in the cookbook. Many variables are being built based on the value of that one attribute, and if you haven't set your override value FIRST, then the values in the cookbook will still win for the derived attributes.
If you set an override on the node or environment for nginx['source']['prefix'] that should work, but it's not ideal. Alternately, also override the derived values.
https://github.com/miketheman/nginx/blob/master/attributes/source.rb
default['nginx']['source']['sbin_path'] = "#{node['nginx']['source']['prefix']}/sbin/nginx"
default['nginx']['source']['default_configure_flags'] = %W(
--prefix=#{node['nginx']['source']['prefix']} # <= this one needs overridden
--conf-path=#{node['nginx']['dir']}/nginx.conf
--sbin-path=#{node['nginx']['source']['sbin_path']}
)
There may be others, but those are the two I know of, and that stand out.

How to determine iTextSharp Basefont default style

I am creating a PDF using iTextSharp.
Part of the process adds straightforward text to the PDF and another part creates an outline of the same text.
For the straighforward text aspect I am using the ShowTextAligned method in iTextSharp; which requires a Basefont and has no way of setting the style.
For the outline I am creating a GDI GraphicsPath to get points, which are then translated into PDF curves/lines etc. The AddString method requires a Drawing.FontStyle
Now my issue is that I need to set the style of AddString to the same one being used by the BaseFont. I.E if the Basefont is rendering Regular, i need to set the AddString fontstyle to regular
How do I determine what style is being used by the BaseFont in ShowTextAligned?
Further info:
I have also tried using ColumnText; which allows you to set an iTextSharp Font, along with it's style. Though using this method results in a font that is rendered with the approximate style; I.E a font usually in regular and set to bold gives a slightly malformed bold font.
EDIT
When I say i need to pass in the BaseFont to ShowTextAligned, What I mean to say is that in order to use this method you have to set the font and size first using SetFontAndSize of the PdfContentByte - it is this method that requires the BaseFont.
I know I must be missing something obvious.. I just can't see the wood for the trees :)
You can try defining your base font beforehand and use it throughout your PDF doc.
See iTextSharp - Working with Fonts
Sample code:
BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
Font times = new Font(bfTimes, 12, Font.ITALIC, Color.RED);
The above lines create a BaseFont object and uses the built-in constant values to set the font family and encoding. It also specifies false for embedding the font within the PDF document. A new Font object is created using the BaseFont object, and further setting the font size in points, the style and the color - again, using iTextSharp's constants for these values.
For more info on BaseFont, see its class definition.
You can use SetColorFill method. Like this
content.BeginText();
BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252,BaseFont.NOT_EMBEDDED);
content.SetFontAndSizebaseFont, 12);
BaseColor baseColor = new BaseColor(255, 0, 0);
content.SetColorFill(baseColor);
//or use predefined colors
content.SetColorFill(BaseColor.RED);
// use ShowTextAligned method
content.EndText();

how change textcolor editor in qt

this is my syntax editor program i want to show keyword,classes,function and ...with Separate color i set the color in config file(with Qsetting)
for example this in my config file :
FunctionColor=blue
an in my cod i read the the configfile:
QString FunctionColor=settings.value("FunctionColor").toString();
how i can set the color in this instruction:
functionFormat.setForeground(Qt::FunctionColor);
compiler gives error? what i must be doing????
It would be great if you provide clear snippet codes instead of the example instructions above. However, based on my guess, if you check Qt documentation,
setForeground
is taking QBrush type of parameter. That means, to get what you want probably, you need to add some logic to convert between the string value to the QBrush value, for example:
if (FunctionColor == "blue")
{
functionFormat.setForeground(Qt::blue);
}
See if this could fix the problem.

Resources