Mathematics in ylabel - expression

Good day
I want to write Ri+ and Ri- (i as subscript and +/- as superscript) on y label in a basic plot function in Rstudio. Also "and" between them. I am trying
expression(italic("R"["i"]^"+"~"R"["i"]^"-"))
But this is not working as I am desired. Please help

Is this what you are trying to do?
expression(paste(italic(R[i]^+phantom(0)),"and", italic(~R[i]^-phantom(0))))

Related

How to draw x=y line in OriginPro

Does anyone know how to draw an exact x=y line in OriginPro scatter plot? I already looked into the Internet and OriginPro forums with no exact solution. Many thanks in advance.
Try this:
Firstly make a column of numbers in Excel (...,-3,-2,-1,0,1,2,3,4,5,...), copy that. Then create a new Book in Origin, paste it in 2 columns: (X) and (Y). After highlight theese 2 columns with your cursor and go to Plot -> Line. That's it.

Scilab 3d Plot Datatips

I am plotting some data in Scilab as 3d-Scatter plot (Scilab 6).
With the datatip toggle it is able to show some information about each data point: x,y,z value.
I am actually plotting node-values, x,y are the coordinates, z is the damage.
Is it possible to change the output of the datatip? I would like to display a node-label instead of the coordinates using the datatip-function!
Thank you!
Use datatipSetDisplay (cf. examples in help page)
You can set a custom diplay function per "PolyLine" object in your plot, e.g.
t=0:0.1:10;y=sin(t);
function s=mydatatip(h),s="DATATIP",end
plot(t,y)
datatipSetDisplay(gca().children(1).children(1),mydatatip)
Please note, here gca().children(1).children(1) is a handle to the "PolyLine" object of the plot.

Change image colormap to deuteranopia in Matlab

I've been trying for a long time to change my colormap of my images using a custom 256x3 colormap to switch the impression of a 'normal sighted' person to the one a person with deuteranopia (red-green-blindness) can see.
The colormap has already been created, but in no way I get to apply it to the original image.
The code
load('ColormapsDefVis.mat')
fig=figure
a=imread('Regenbogen.png');
[b map]=rgb2ind(a,256);
c=ind2rgb(b, DeuteranopiaColorMap);
imshow(c);
did not work as well as
load('ColormapsDefVis.mat')
fig=figure
a=imread('Regenbogen.png');
imshow(a);
set(fig,'Colormap',DeuteranopiaColorMap)
did not.
Does anyone know how to change the custom colormap correctly?
I would appreciate your help very much!
The first peice of code works. You have to be making a mistake or interpreting the results wrongly.
I suggest you look a to a thing. Make sure you image is unit8 or single. Additionally, you probably dont what dithering to happen, so I suggest you do rgb2ind(a,256, 'nodither'). The results of the dithering may be fooling your eyes, but we can't know as you didn't post any image.
To convince yourself that rgb2ind works, see the code below. You should be able to test it in you computer.
img=imread('cameraman.tif');
indimg=img;
cmap=hsv(255); % colromap 1
cmap2=cmap(end:-1:1,:); % colromap 2
subplot(121);
c=ind2rgb(indimg,cmap );
imshow(c)
subplot(122);
c2=ind2rgb(indimg,cmap2 );
imshow(c2)
Thank you very much for your help Ander, the approach using colormaps was just not the efficient solution i was looking for. Although I am sure it would work too, there is a way easier solution for the problem :)
To receive the impression of being red-green-blind I took the idea that people suffering from this condition cannot distinguish between reddish and greenish objects. So my solution is to plot the mean from the red and green RGB-image channel in both channels to make them indistinguishable.
a=imread('peppers.png');
figure,
subplot(121)
imshow(a)
c=(a(:,:,1)+a(:,:,2))/2; %Mean value between channel red and green
a(:,:,1)=c; %Switch the red channel to the mean
a(:,:,2)=c; %Switch the green channel to the mean
subplot(122)
imshow(a)
Unfortunately, stackoverflow refuses me to upload images as I do not have enough reputation, but the code shall work using any RGB-image, for example the builtin demo image 'peppers.png'.
Hope this helps anyone else too!

Plot time series and image in R so that x axis labels line up perfectly

I am trying to plot a time series (a seismograph) with a corresponding spectrogram in R.
Since I would like to compare the time series with the spectrogram, the X axis labels on the time series need to line up with the X axis labels on the spectrogram. However, I'm having a lot of trouble with this. The best I've been able to do so far is use
par(mar=c(0,10,0,8))
and try to manually force the spectrogram labels to line up with the time series labels by tweaking the spectrogram margin. Of course this is only approximate and they still do not line up perfectly. Is there a way to make the axes generated by the code below match up with each other?
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l",xlab="Time",
ylab="Amplitude", main="Time Series", xlim=c(1,10))
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram", xlim=c(1,10))
Thanks in advance!
This seems to work:
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l", xaxs="i")
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram")
Just drop the xlim= arguments and use xaxs="i" in the plot() function to match the default for image().
You can either add xaxs='i' to the call to plot (this removes the extra padding so it lines up with the image plot), or you could use par('usr') after the 1st plot to see what the x limits are and use those values in the xlim call in image.
It turns out that this is way easier than it looked initially. The secret is to make a "dummy plot" and then add the image to the plot. So here's how the new, working code looks:
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01),
type="l",xlab="Time",ylab="Amplitude", main="Time Series")
plot(c(0,10), c(0,10), type="n") #Dummy plot with axis limits for our spectrogram
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram",add=TRUE)
Similar, but conversely, to Greg Snow's answer, you could add xaxs='r' to the call to image as follows:
par(mar=c(0,10,0,8))
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l",xlab="Time",
ylab="Amplitude", main="Time Series", xlim=c(1,10))
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram", xlim=c(1,10), xaxs="r")
Don't forget to save your par() setting first.
(maybe I should have put that above)

How to display y Axis on the right side on Graph

I want to implement a candlestick graph using core-plot. I have a little problem with yAxis. I'd like to display the yAxix on the right like this examples:
http://www.schaefferresearch.com/images/schaeffersu/tutorials/charts/candlestick.gif
http://www.mafiaforex.com/wp-content/uploads/2010/07/candlestick.gif
How?!
Looking at the examples I tried to change yAxis.orthogonalCoordinateDecimal with no result.
Thank you for your help!
Bye
G.
Try changing xAxis.orthogonalCoordinateDecimal.
yAxis.axisConstraints = [CPTConstraints constraintWithUpperOffset:0.0];
yAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble("some number on X axis");
should work.

Resources