Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a standard way of how to add markers to the x- and y-axes? #735

Closed
q2apro opened this issue Jan 14, 2019 · 4 comments
Closed

Is there a standard way of how to add markers to the x- and y-axes? #735

q2apro opened this issue Jan 14, 2019 · 4 comments

Comments

@q2apro
Copy link

q2apro commented Jan 14, 2019

With:

    ports: [{
        id: "CSCanvas",
	axes: true,
	grid: true,

the x-y-axes show up, and the nice grid.

Is there a standard way of how to set markers at the axes?

For instance, every 1 unit a "1", "2", ... and a little visual marker -.

Example:

image

@montaga
Copy link
Member

montaga commented Jan 14, 2019

as far as I know,the answer is no. You have to script that.

@montaga montaga closed this as completed Jan 14, 2019
@q2apro
Copy link
Author

q2apro commented Jan 15, 2019

This is one possible solution (scripting it oneself):

// coordinate markers and labels for x-axis and y-axis
list = -4..4;
repeat(
	length(list),
	draw((-0.1,list_#),(0.1,list_#), color->(0.75, 0.75, 0.75));
	draw( (list_#,-0.1),(list_#,0.1), color->(0.75, 0.75, 0.75) );
	if(
		list_#!=0, 
		drawtext( (-0.49, list_#-0.08), list_#, size->10, color->(0.5,0.5,0.5) );
		drawtext( (list_#, -0.5), list_#, size->10, color->(0.5,0.5,0.5), align->"center" );
	);
);

@kortenkamp
Copy link
Member

kortenkamp commented Jan 15, 2019

The code could be simplified slightly:

list = -4..4;
forall(list,
	draw((-0.1,#),(0.1,#), color->(0.75, 0.75, 0.75));
	draw( (#,-0.1),(#,0.1), color->(0.75, 0.75, 0.75) );
	if(
		#!=0, 
		drawtext( (-0.49, #-0.08), #, size->10, color->(0.5,0.5,0.5) );
		drawtext( (#, -0.5), #, size->10, color->(0.5,0.5,0.5), align->"center" );
	);
);

@q2apro
Copy link
Author

q2apro commented Jan 15, 2019

Nice, thanks!

Used here now: https://www.matheretter.de/wiki/punkt#neg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants