Labelling X and Y axis in Dymola plot - plot

I have drawn a plot using "plotArrays" function in Dymola. I would like to label X-axis in meters(Ideally, I need it to be flexible so that I can later change it to millimeters, micrometers, etc..). I want to label Y-axis similarly in volts which I have done already using
plotArrays(x_axis,phie,legend=names,units=fill("V",size(phie,2)));
and I can read the values in volts and also change to mV etc.. However, its not 'visible' in Y-axis as you can see in the plot below. So, How can I label the axes separately?
Thanks a lot!

I don't know any more efficient possibility than this:
createPlot(id=1, erase=false, grid=true, leftTitleType=2, leftTitle="myLabelY", bottomTitleType=2, bottomTitle="myLabelX")
with:
id being the number shown in the original plot
erase=false to ensure that the content is not modified
grid=true (re-)enabling the grid
*TitleType=2 saying that there is a custom title
*Title being the string to put there
This will result in the plot being resized to the default size. You can use plotSetup() to get the current setup, including position, which you can then pass (manually) to the createPlot() command to result in the original size again.
Not very elegant, but I don't know any other possibility...

Related

Increase Labelsize in Julia Plots

I am creating a plot using Plots in Julia. I was trying to increase the size of the labels and also the values on the axes but couldn't find the right keyword arg (I thought it was annotationfontsize but that doesn't seem to work). Does anyone know the right arg?
I think you're looking for guidefontsize and tickfontsize. You can check all the axis attributes in the documentation. For example,
julia> plot(rand(10); xtickfontsize=5, xlab="Big label, small tick labels", xguidefontsize=20)
will give you something like

Multiple axes in Julia Plots (GR backend)

How do I plot a set of curves with Julia (1.4.1) and Plots in a Jupyter notebook, some of them using the x axis and the left y axis, and some (more than one!) using the x axis and the right y axis? Whatever I try, I always get only one plot (the first one, which gets the twinx command) to use the right y axis, whereas the ones following it use the first (left) axis again. Among several other things, I tried
epl=plot(title="A title",legend=:topright)
epl=plot!(x_arr,y1_arr)
epl=plot!(x_arr,y2_arr)
epl=plot!(twinx(),x_arr,y3_arr,legend=:bottomright)
epl=plot!(x_arr,y4_arr)
display((epl))
and also
epl=plot(title="A title",legend=:topright)
epl=plot!(x_arr,[y1_arr,y2_arr])
epl=plot!(twinx(),x_arr,[y3_arr,y4_arr],legend=:bottomright)
display((epl))
The latter works a bit better, but I don't know how to define individual linestyles, legend labels etc. for each vector element; my attempt to assign matching vectors to the corresponding keyword arguments failed. The label for the second y axis (not included in the example above) does not show up either. The legend is wrong in the first case and does not show up at all in the second case.
The interface I use is apparently gr(), which I tend to prefer, but I'm not sure.
The plot! function takes an optional first plot object to modify. If you don't pass in a plot to be modified, it uses the global one.
When you call twinx(), it creates a new subplot that you can plot! into — one that's inside your current global plot — and then it updates and returns the overall plot. Your next plot! just updates the first subplot as usual.
The key is to save your twinned subplot and explicitly plot! into it.
epl=plot(title="A title", legend=:topright)
plot!(x_arr, y1_arr) # could be explicitly `plot!(epl, x_arr, y1_arr)`
plot!(x_arr, y2_arr)
subplot = twinx()
plot!(subplot, x_arr, y3_arr, legend=:bottomright)
plot!(subplot, x_arr, y4_arr)

How to expand your plot so all labels can be seen without overlapping in R

I have a plot with 50 categories(states) that show on my X axis, but in my output they are on top of each other. I want my plot to be spread out engough/large enough that there is no overlap and you could determine the state value from the next.
NOTE: i used the coord_flip command, so I know that my X-axis is actually my Y in image and vice versa. I am just wondering what function I would use to fix problem.
You can always change the size of the text via themes(axis.text.x=element_text(size=...))...
But the easy answer here is that your plot will change appearance based on the aspect ratio. When you view in Rstudio, you can adjust the size of your plot and you'll see the rearrangement. Additionally, when you save, the plot, play around in particular to the height and width to get the ratio you want. ggsave('filename.png', width=??, height=??).

In Stata, how do I modify axes of dot chart?

I'm trying to create a dot chart in Stata, splitting it into two categories
Running a chunk of code:
sysuse nlsw88, clear
drop if race == 3
graph dot (mean) wage, over(occ) by(race)
Creates such output:
So far so good but I'd like to remove labels of Y axis from the right graph to give the data some more space.
The only way I've been able to do that was to manually edit graph and hide the axis label object:
Is there a way to do it programmatically? I do know I could use one more over() but in some graphs of mine that is already taken.
I believe the solution is buried in help bystyle and help by_option. However, I can't get it to work with your example (I'm on Stata 12). But the description is clear. For example:
A bystyle determines the overall look of the combined graphs,
including
whether the individual graphs have their own axes and labels or if instead the axes and labels are shared across graphs arrayed in the
same row and/or in the same column;
...
There are options that let you control each of the above attributes --
see [G-3] by_option --
And also
iyaxes and ixaxes (and noiyaxes and noixaxes) specify whether the y axes and x axes are
to be displayed with each graph. The default
with most styles and
schemes is to place y axes on the leftmost graph of each row and to place x axes on
the bottommost graph of each column. The y and
x axes include the
default ticks and labels but exclude the axes titles.
If for some reason that doesn't work out, something like
sysuse nlsw88, clear
drop if race == 3
graph dot (mean) wage, over(occ) by(race)
gr_edit .plotregion1.grpaxis[2].draw_view.setstyle, style(no)
does (but I don't really like the approach). You can mess with at least the axis number [#] to do a bit of customization. I guess recording changes in the graphical editor and then recycling the corresponding code, may be one way out of difficult situations.

How to plot just one axis label in R?

A beginner question: I currently have some plots that look like this.
I'm keeping the plots free of other annotation because I have to fit a lot of them onto one page and specific values aren't important, just the general trend that the red line is to the right of the black one. However, I'd like to be able to indicate that the dashed line in my plot actually represents zero, like so:
Is there any way to tell R to only display that value on the x-axis labels? I don't think using text() would be a good idea because it relies on absolute coordinates, but I'm not really sure how to work with axis options to make it do what I want.
Try:
axis(side = 1, at = 0)
See ?axis for details.

Resources