Syntax of semilogx, semilogy, loglog

Hi,
I just realized that the following syntaxes are not valid
semilogx(X1,Y1,LineSpec,'PropertyName',PropertyValue)
semilogy(X1,Y1,LineSpec,'PropertyName',PropertyValue)
loglog(X1,Y1,LineSpec,'PropertyName',PropertyValue)
whereas
plot(X1,Y1,LineSpec,'PropertyName',PropertyValue)
is valid. Shouldn't this be fixed for consistency?

 Respuesta aceptada

Wayne King
Wayne King el 26 de Sept. de 2011
Hi Nicolas, Can you give an example?
x = logspace(-1,2);
loglog(x,exp(x),'-s','linewidth',2)
figure;
x = 0:0.1:10;
semilogx(10.^x,x,'r--','linewidth',2)

5 comentarios

Nicolas
Nicolas el 26 de Sept. de 2011
My mistake, sorry. Got an error due to another bug and thought its due to loglog, since the above syntax is not documented.
Wayne King
Wayne King el 26 de Sept. de 2011
Glad to hear it's working. Just out of curiousity, which version of MATLAB are you using that the above is not documented?
I see this documented for loglog all the way back to at least 2005.
Nicolas
Nicolas el 26 de Sept. de 2011
I am using using R2011a. I was referring to the help entry of loglog. There it sais:
Syntax
loglog(Y)
loglog(X1,Y1,...)
loglog(X1,Y1,LineSpec,...)
loglog(...,'PropertyName',PropertyValue,...)
h = loglog(...)
Nicolas
Nicolas el 26 de Sept. de 2011
On the other hand for plot it sais:
Syntax
plot(Y)
plot(X1,Y1,...,Xn,Yn)
plot(X1,Y1,LineSpec,...,Xn,Yn,LineSpec)
plot(X1,Y1,LineSpec,'PropertyName',PropertyValue)
plot(axes_handle,X1,Y1,LineSpec,'PropertyName',PropertyValue)
h = plot(X1,Y1,LineSpec,'PropertyName',PropertyValue)
Guess I wasn't interpreting the ... properly.
Wayne King
Wayne King el 26 de Sept. de 2011
Right:
loglog(X1,Y1,LineSpec,....)
means:
x = logspace(-1,2);
loglog(x,exp(x),'-or')
or some other valid linespec (the 'or' is a linespec)
loglog(...,'PropertyName',PropertyValue,...)
means:
loglog(x,exp(x),'linewidth',2,'LineStyle','-.');
or some valid 'PropertyName',PropertyValue combination.
Glad it's working!

Iniciar sesión para comentar.

Más respuestas (2)

UJJWAL
UJJWAL el 26 de Sept. de 2011
Things are working ok... There is no inconsistency or I was not able to understand you.. Please check the following code and rephrase the question so that I would understand better :-
clc
clear all
t= 0:0.001:2;
plot(t,exp(t),'--.r','LineWidth',2);
figure(2);
semilogx(t,exp(t),'*k','LineWidth',2);
figure(3);
semilogy(t,exp(t),'-.b','LineWidth',2);
figure(4);
loglog(t,exp(t),'--y','LineWidth',2);
Khaleel UR Rehman Khan
Khaleel UR Rehman Khan el 23 de Jun. de 2020

0 votos

If suppose we have to make the linewidth=3,
loglog(x,y,'linewidth',3) is wrong
the right syntax is
loglog(x,y,"Linewidth",3)

1 comentario

loglog accepts the name of a name-value pair argument as a char vector or as a string perfectly fine when I tried it in release R2020a. Can you clarify why you believe the syntax with the name specified as a char vector is wrong? If you're seeing an error can you show all of the error message (all the text displayed in red?)
x = 1:10;
y = x.^2;
figure
loglog(x, y, 'linewidth', 3)
figure
loglog(x, y, "linewidth", 3)

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 26 de Sept. de 2011

Comentada:

el 23 de Jun. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by