Axis width/thickness in ggtern - ggtern

A simple - and possible elementary - question that I have not been able to find an answer for:
How do I change/manage the axis width/thickness in ggtern?
Looks like the usual commands for that does not apply to ggtern
Help would be highly appreciated
Thanks in advance
Lars

This is controlled by the new theme elements which are unique to ggtern, consider below some examples, which should be fairly self-explanatory:
library(ggtern)
base = ggtern() + theme_bw()
#All Axes
base + theme(tern.axis.line = element_line(color='red',size=2))
#Individual Axes
base + theme(tern.axis.line.T = element_line(color='red',size=2))
base + theme(tern.axis.line.L = element_line(color='green',size=2))
base + theme(tern.axis.line.R = element_line(color='blue',size=2))

Related

Can I use Lattice auto.key or key to make a legend with points for some data and lines for others?

I often make figures that have observed data represented as points and model-predicted data represented as lines, using distribute.type to assign graph types. Is there a way to make a legend that only shows points for the points data, and lines for the lines data? The auto.key default is points, and if I add lines with "list(lines=TRUE)" the legend shows both points and lines for every data label:
x <- seq(0, 8*pi, by=pi/6)
Y1pred <- sin(x)
Y1obs <- Y1pred + rnorm(length(x), mean=0, sd=0.2)
Y2pred <- cos(x)
Y2obs <- Y2pred + rnorm(length(x), mean=0, sd=0.4)
xyplot(Y1obs + Y2obs + Y1pred + Y2pred ~ x,
type=c('p','p','l','l'),
distribute.type=TRUE,
auto.key=list(lines=TRUE, columns=2)
)
There is a rather complicated example using 'key' on p. 158 of Deepayans' book on Lattice, I am wondering if there are simple options?
Yes, following S, the lines components of key supports different type-s (but not points). Using auto.key, you could do
xyplot(Y1obs + Y2obs + Y1pred + Y2pred ~ x,
type=c('p','p','l','l'),
distribute.type=TRUE,
auto.key = list(points = FALSE, lines = TRUE,
columns = 2,
type = c('p','p','l','l')))
Ideally, you would want to put the type only inside the lines component, and that's how you should do it if you use key. For auto.key, there can be only one line anyway, so this should be fine.

What does O(nm/8 * log(nm/8)) + O(nm/9 * log(nm/9)) + ... + O(nm/m * log(nm/m)) equal to?

I'm sorry for the question title but I can't find a simpler way to put it. Basically, my algorithm involves quicksort for O(nm/k) elements, where k ranges from 8 to m. I wonder what the total complexity for this is, and how to deduce it? Thank you!
Drop the division inside the logarithms and we get nmlog(mn) * (1/8 + ... + 1/m) = O(nmlog(mn)log(m)) = O(mnlog(m)^2 + mnlog(m)log(n)). [I used the fact that the harmonic series is asymptotically ln(m))
Note that the fact that we dropped the divisions inside the logarithms means that we got an upper bound rather than an exact bound (but a better one than the naive approach of taking the biggest term multiplied by m).

How to solve mixed differential equations? Or how to assign the dPsdt = o in first iteration and it will get value after iterations

Error generates like this: UnboundLocalError: local variable 'dPsdt' referenced before assignment
dL1dt = (m_si*(h1-hf) + pi*di*alphai_1*L1*(Tm1-Ts1) - d13*dPsdt)/d11
dL2dt = (m_si*hf-m_so*hg + pi*di*alphai_2*L2*(Tm2-Ts2)- d21 * dL1dt -d23*dPsdt-
d24*dhodt)/d22
dPsdt = (m_so*(hg-ho) + pi*di*alphai_3*L3*(Tm3-Ts3)-d31*dL1dt-d32*dL2dt -
d34*dhodt)/d33
dhodt = (m_si - m_so -(d41*dL1dt) - (d42*dL2dt) - (d43*dPsdt))/d44
dzdt = [dL1dt, dL2dt, dPsdt, dhodt, dTm1dt, dTm2dt, dTm3dt, dTp1dt, dTp2dt, dTp3dt]
return dzdt
It seems that your derivatives are implicitly defined by some linear system
A*dxdt = b
which you try to solve via Gauss-Seidel iteration. This you have to actually implement as iteration, that is, several passes over the system of equations. Note that you need a convergence condition like diagonal dominance so that that works at all.
But for these small dimensions you can be faster and more exact by using
dxdt = nump.linalg.solve(A,b)

Big O Sum should be accounted?

I have an algorithm that the solutions are k sum of things there is a formula to show that? Or is simply the biggest one?
O(k^n + k^(n-1) + k^(n-2) ... + k^0) is O(k^n) or there is a way of representing this?
Thanks is advance

Wolfram Alpha Solution Entry

Using this Wolfram Alpha code either through web or in Mathematica:
(5y^4+3y^2+e^y)y'=cos(x),y(0)=0
My equation seems to be properly parsed:
{(5 y(x)^4 + 3 y(x)^2 + e^(y(x))) y'(x) = cos(x), y(0) = 0}
As a separable DE, the result should be:
y^5 + y^3 + e^y = sin(x) + 1
How do I modify the original Wolfram Alpha code to get the program to evaluate the solution?
Using Wolfram Alpha
{(5y[x]^4+3y[x]^2+E^y[x])y'[x]==Cos[x],y[0]==0} solution